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.   

        class Program
        {
            static void Main(string[] args)
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(@"c:\1.xml");
                XmlNode node = xmldoc.SelectSingleNode("//return");
                string str = node.Attributes[0].Value;
                Console.ReadKey();
            }
        }
    integer的值只需要将SelectSingleNode定位到integer就可以了
      

  3.   

    class Program
        {
            static void Main(string[] args)
            {
                string path = Path.GetFullPath("../../Files/Test.xml");
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                XmlNode xn = doc.SelectSingleNode("return");
                string attr = xn.Attributes["msgid"].Value;
                Console.WriteLine(attr);            XmlNode xnTwo = doc.SelectSingleNode("return/arguments/integer[@id='result']");
                Console.WriteLine(xnTwo.InnerText);            Console.Read();
            }
        }
    path根据具体情况改变。