如: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
谢谢~~

解决方案 »

  1.   

    直接用xml的方式读取不好吗?
      

  2.   

    转成xmldocument,使用xpath查询岂不更好?
      

  3.   

    加载到xmldocument后再查询,好像有个selectnodebyid方法
      

  4.   

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("aaa");先转换过来哈
    然后其下节点
      

  5.   

    等待答案 也想学习Ixia 
      

  6.   


    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;