我的 .XML 数据库如下所示:
<root>
<Lemma>
<Lemma.LemmaSign>cat</Lemma.LemmaSign>
<Lemma.PartOfSpeech>(noun)</Lemma.PartOfSpeech>
<Lemma.UsageLabel>(kt)</Lemma.UsageLabel>
<Sense>
<TE>
<TE.TE> animal</TE.TE>
</TE>
<Pronunciation>/
<Pronunciation.Pronunciation>[coot]</Pronunciation.Pronunciation>/
</Pronunciation>
:
<Example>
<Example.Example> it's a cat</Example.Example>
<Example.Translation> it's animal</Example.Translation>
|
</Example>
</Sense>
</Lemma>
</root>
这就是我的代码:
var elements = XElement.Load("objects.xml");
var query1 = from query in elements.Descendants("Lemma")
let null_LemmaSign = query.Element("Lemma.LemmaSign")
let null_TE = query.Element("TE.TE")
where wyszuk == query.Element("Lemma.LemmaSign").Value
select new
{
word = null_LemmaSign == null ? "none" : null_LemmaSign.Value,
te = null_TE == null ? "none" : null_TE.Value,
};
foreach (var e in query1)
{
MessageBox.Show(e.word.ToString() + " - " + e.te.ToString());
}
问题是输出看起来像: cat - none 并且应该是 cat - animal
如何从我的 .xml 中获取 TE.TE?