
C# 怎样读XML文件
C#怎样读取以下XML文件的各项值请高手指教,谢谢了<result><status>1</status><info>正常</info><infoCode>00000</i...
C# 怎样读取以下XML文件的各项值
请高手指教,谢谢了
<result>
<status>1</status>
<info>正常</info>
<infoCode>00000</infoCode>
<data>
<totalrecords>2</totalrecords>
<orderlist>
<order>
<recordno>10001</recordno>
<kuid>12345</kuid>
<id>order12345</id>
<totaldetails>2</totaldetails>
<detaillist>
<detail>
<recordno>1</recordno>
<itemname>商品1</itemname>
<price>100</price>
</detail>
<detail>
<recordno>2</recordno>
<itemname>商品2</itemname>
<price>200</price>
</detail>
</detaillist>
</order>
<order>
<recordno>10002</recordno>
<kuid>12345</kuid>
<id>order23456</id>
<totaldetails>1</totaldetails>
<detaillist>
<detail>
<recordno>1</recordno>
<itemname>商品a</itemname>
<price>300</price>
</detail>
</detaillist>
</order>
</orderlist>
</data>
</result> 展开
请高手指教,谢谢了
<result>
<status>1</status>
<info>正常</info>
<infoCode>00000</infoCode>
<data>
<totalrecords>2</totalrecords>
<orderlist>
<order>
<recordno>10001</recordno>
<kuid>12345</kuid>
<id>order12345</id>
<totaldetails>2</totaldetails>
<detaillist>
<detail>
<recordno>1</recordno>
<itemname>商品1</itemname>
<price>100</price>
</detail>
<detail>
<recordno>2</recordno>
<itemname>商品2</itemname>
<price>200</price>
</detail>
</detaillist>
</order>
<order>
<recordno>10002</recordno>
<kuid>12345</kuid>
<id>order23456</id>
<totaldetails>1</totaldetails>
<detaillist>
<detail>
<recordno>1</recordno>
<itemname>商品a</itemname>
<price>300</price>
</detail>
</detaillist>
</order>
</orderlist>
</data>
</result> 展开
2个回答
展开全部
给一个简单的例子
XML文件内容:
<?xml version="1.0" standalone="yes"?>
<name>
<A>张三</A>
<B>李四</B>
<C>王五</C>
</name>
读取“张三”的名字:
XmlDocument xmlDoc1 = new XmlDocument();
xmlDoc1.Load(@"xmlname.xml");
string sdr = "";
sdr = xmlDoc1.SelectSingleNode("name/A").InnerXml;
XML文件内容:
<?xml version="1.0" standalone="yes"?>
<name>
<A>张三</A>
<B>李四</B>
<C>王五</C>
</name>
读取“张三”的名字:
XmlDocument xmlDoc1 = new XmlDocument();
xmlDoc1.Load(@"xmlname.xml");
string sdr = "";
sdr = xmlDoc1.SelectSingleNode("name/A").InnerXml;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询