XML文件如下:
<return msgid="123"> 
  < arguments >
    <string id="devicecode">ZHAOYINGBI</string>
    <string id="command">OPENDEV</string>
    <integer id="result">0</integer>
  </arguments>
</return>1. 获取<return msgid="123"> 中的msgid的值。
2. 获取<integer id="result">0</integer> 的值(即 0)。
请高手指教!万分感激!!!

解决方案 »

  1.   

    XmlDocument    类 搜下msdn
     
    此消息通过 【CSDN论坛 Winform正式版】 回复!有关此工具
      

  2.   

    _xmlDoc.Load(xmlPath);   //载入Xml文档XmlNode firstNode = _xmlDoc.SelectSingleNode("return");
    if (firstNode != null)
    {
    XmlAttributeCollection xmlAttributes = node.Attributes;
    msgid = xmlAttributes["msgid"].Value;
    XmlNodeList nodes = firstNode.SelectSingleNode("arguments").SelectNodes("string");
    if (nodes != null)
    {
    foreach (XmlNode node in nodes)
    {
    XmlAttributeCollection xmlAttributes = node.Attributes;
    if (xmlAttributes["id"].Value == "result")
    {
    itemText = xmlAttributes[itemValueName].InnerText;
    break;
    }
    }
    }
    }
    好像整复杂了。
      

  3.   

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(Server.MapPath(@"c:\test.xml"));
    Console.WriteLine(xmlDoc.DocumentElement.Attributes["msgid"].Value);
    Console.WriteLine(xmlDoc.SelectSingleNode(@"//integer[@id='result']").InnerText);
      

  4.   

    更正一下:第二句是xmlDoc.Load(@"c:\test.xml");