【发布时间】:2013-04-02 08:45:10
【问题描述】:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Fruits>
<Fruit>hahahaha</Fruit>
</Fruits>
</Root>
如果我试试这段代码,
string[] cFruitName; int i=0;
XmlDocument a= new XmlDocument();
a.LoadXml(getXML());
foreach (XmlNode xn in a)
{
cFruitName[i] = xn.Text;
i++;
}
但我得到null 为xn.Text。
我想要的只是获取水果的值,例如本例中的“hahahah”。
编辑
我现在更改了我的 XML。
【问题讨论】:
-
Fruit里面为什么会有水果
-
有没有更好的方法,请告诉我