获取Xml中指定子节点值

前端之家收集整理的这篇文章主要介绍了获取Xml中指定子节点值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
待处理的Xml文件
<?xml version="1.0" encoding='UTF-8'?>
<ufinterface billtype="gl" filename="gledi" isexchange="Y" proc="add" receiver="01" replace="Y" roottag="sendresult" sender="ceec" successful="Y">
	<sendresult>
		<billpk>
		</billpk>
		<bdocid>AAAA</bdocid>
		<filename>BBBB</filename>
		<resultcode>CCCC</resultcode>
		<resultdescription>DDDD</resultdescription>
		<content>EEEE</content>
	</sendresult>
	<sendresult>
		<billpk>
		</billpk>
		<bdocid>aaaa</bdocid>
		<filename>bbbb</filename>
		<resultcode>cccc</resultcode>
		<resultdescription>dddd</resultdescription>
		<content>eeee</content>
	</sendresult>
</ufinterface>
//获取<sendresult>节点下<bdocid>与<resultdescription>的值
XmlDocument Xd = new XmlDocument();
Xd.Load("E:\\Books.xml");
XmlNode Sroot = Xd.SelectSingleNode("//sendresult");
Pzbh = (Sroot.SelectSingleNode("bdocid")).InnerText;
Djxx = (Sroot.SelectSingleNode("resultdescription")).InnerText;
原文链接:https://www.f2er.com/xml/299302.html

猜你在找的XML相关文章