<vocabularyList>
<attribute>
<name>unit2</name>
<wordsAmount>1</wordsAmount>
<description>´�¢ԯ</description>
<buildDate>2008-12-23 16:20:02</buildDate>
<author>wang</author>
<allowModify>false</allowModify>
</attribute>
<wordList>
<word>banana</word>
<word>apple</word>
</wordList>
</vocabularyList> 上面这个xml文件是符合要求的吗???
如果是的话,我想得到banana、apple怎么办???
<attribute>
<name>unit2</name>
<wordsAmount>1</wordsAmount>
<description>´�¢ԯ</description>
<buildDate>2008-12-23 16:20:02</buildDate>
<author>wang</author>
<allowModify>false</allowModify>
</attribute>
<wordList>
<word>banana</word>
<word>apple</word>
</wordList>
</vocabularyList> 上面这个xml文件是符合要求的吗???
如果是的话,我想得到banana、apple怎么办???
<attribute>
<name>unit2 </name>
<wordsAmount>1 </wordsAmount>
<description>´�¢ԯ </description>
<buildDate>2008-12-23 16:20:02 </buildDate>
<author>wang </author>
<allowModify>false </allowModify>
</attribute>
<wordList>
<word>banana </word>
<word>apple </word>
</wordList>
</vocabularyList>
"; XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList list = doc.GetElementsByTagName("wordList");
foreach (XmlNode node in list)
{
string banner = node.ChildNodes[0].InnerText;
string apple = node.ChildNodes[1].InnerText;
}
doc.Load(文件);
XmlNodeList list = doc.SelectNodes("/vocabularyList/wordList/word");
foreach(XmlNode node in list)
{
Console.WriteLine(node.InnerText);
}