using System.xml.linq;
XDocument doc=XDocument.Load("xml文档");
if(doc.Element("rtnCode").Value=="000"){}
手写板。。可能有错误

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplicationTest
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                String xml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?>  
                              <Package>
                              <totalCount>45</totalCount>  
                              <MaxId>2878419</MaxId>  
                              <Message>
                              <DeliverMessage>
                              <Id>2878419</Id>  
                              <Userid>guodcy</Userid>  
                              <Srctermid>07168305533</Srctermid>  
                              <Desttermid>07168305533</Desttermid>  
                              <Content>湖电信测试</Content>  
                              <Receivetime>2010-06-27 21:26:54.0</Receivetime>  
                              </DeliverMessage>
                              </Message>
                              </Package>";
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.LoadXml(xml);
                //Console.WriteLine("totalCount : " + doc.GetElementsByTagName("totalCount")[0].FirstChild.Value);
                textBox1.Text = "total:"+doc.GetElementsByTagName("totalCount")[0].FirstChild.Value+"\r\n";
                foreach (System.Xml.XmlNode node in doc.GetElementsByTagName("DeliverMessage"))
                {
                    textBox1.Text = textBox1.Text + "id:" + node["Id"].FirstChild.Value + "\r\n";
                    textBox1.Text = textBox1.Text + "Userid:" + node["Userid"].FirstChild.Value + "\r\n";
                    textBox1.Text = textBox1.Text + "Srctermid:" + node["Srctermid"].FirstChild.Value + "\r\n";
                    textBox1.Text = textBox1.Text + "Desttermid:" + node["Desttermid"].FirstChild.Value + "\r\n";
                    textBox1.Text = textBox1.Text + "Content:" + node["Content"].FirstChild.Value + "\r\n";
                    textBox1.Text = textBox1.Text + "Receivetime:" + node["Receivetime"].FirstChild.Value + "\r\n";
                }
            }
        }
    }
      

  2.   

    using System;
    using System.Windows.Forms;
    using System.Xml;namespace xmlNode
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load("1.xml");
                XmlNode xn = xmldoc.SelectSingleNode("items/rtnCode");
                string s = xn.InnerText;
            }
        }
    }s就是 你要的值  你再根据这个值判断 执行啥子
      

  3.   

    XmlDocument doc=new XmlDocument("");
    doc.Load("");
    XmlNode node=doc.SelectSingleNode("//rtnCode");
    if(node!=null){}
      

  4.   

    XmlNode node=XmlDocment.SelectSingleNode("//itmes//rtncode"); 
    可以参考
    http://www.w3school.com.cn/xmldom/met_node_selectsinglenode.asp
      

  5.   

    XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load("xml路径");
                XmlNode node= xmldoc.SelectSingleNode("//rtnCode");
                if(node!=null)
                string s = node.InnerText;