<?xml version="1.0" standalone="yes" ?>
<customer>
<goo cost="150.0000" date="2007-3-16 8:13:30" />
<info>aa</info>
</customer>怎么获得info节点的值,,只能使用dataset。

解决方案 »

  1.   

    #region GetDataViewByXml
    /// 
    /// 读取Xml返回一个经排序或筛选后的DataView
    /// 
    /// 
    /// 筛选条件,如:"name = 'kgdiwss'"
    /// 排序条件,如:"Id desc"
    /// 
    public static DataView GetDataViewByXml(string strXmlPath,string strWhere,string strSort)
    {
    try
    {
    DataSet ds = new DataSet();
    ds.ReadXml(GetXmlFullPath(strXmlPath));
    DataView dv = new DataView(ds.Tables[0]);
    if(strSort != null)
    {
    dv.Sort = strSort;
    }
    if(strWhere != null)
    {
    dv.RowFilter = strWhere;
    }
    return dv;
    }
    catch(Exception)
    {
    return null;
    }
    }
    #endregion
      

  2.   

    //smtpXmlPath xml文件的路径
    public void loadSmtpInfo(string smtpXmlPath)
    {
    XmlDocument xmldocument = new XmlDocument();
    xmldocument.Load(smtpXmlPath);

    XmlNodeList nodelist = xmldocument.GetElementsByTagName("smtp");

                            string info;
    foreach(XmlNode node in nodelist)
    {
    this.info= node["info"].InnerXml;

    }

    }
      

  3.   

    怎么获得info节点的值,,只能使用dataset。
      

  4.   

    //smtpXmlPath xml文件的路径
    public void loadSmtpInfo(string smtpXmlPath)
    {
    XmlDocument xmldocument = new XmlDocument();
    xmldocument.Load(smtpXmlPath);XmlNodeList nodelist = xmldocument.GetElementsByTagName("customer");string info;
    foreach(XmlNode node in nodelist)
    {
    this.info= node["info"].InnerXml;}}
      

  5.   

    怎么获得info节点的值,,只能使用dataset!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!楼上的兄弟,看清楚要求嘛。
      

  6.   

    DataSet ds = new DataSet();
                ds.ReadXml(file);
                DataTable dt = ds.Tables["customer"];
                MessageBox.Show(dt.Rows[0]["info"].ToString());