如:string aaa = "<?xml version=\"1.0\" encoding=\"GB2312\" ?><fill version=\"1.0\"><items><item name=\"state\" value=\"0\" /><item name=\"errcode\" value=\"2009\" /><item name=\"errmsg\" value=\"您的卡号密码重复使用\" /><item name=\"\" value=\"[email protected]\" /></items></fill>";
我要读取errcode,结果应该是2009
谢谢~~
我要读取errcode,结果应该是2009
谢谢~~
doc.LoadXml("aaa");先转换过来哈
然后其下节点
string aaa = "<?xml version=\"1.0\" encoding=\"GB2312\" ?><fill version=\"1.0\"><items><item name=\"state\" value=\"0\" /><item name=\"errcode\" value=\"2009\" /><item name=\"errmsg\" value=\"您的卡号密码重复使用\" /><item name=\"\" value=\"[email protected]\" /></items></fill>";
XmlDocument xml = new XmlDocument();
xml.LoadXml(aaa);
XmlNode node = xml.SelectSingleNode("//item[@name='errcode']");
string value = node.Attributes["value"].Value;