DataSet result = new DataSet();
string xml=result.GetXml();以下是xml的值,要怎么能得到各个节点的值
<NewDataSet>
  <Weather>
    <Date>2012年05月02日</Date>
    <Week>星期三(Wed)</Week>
    <Weather>Mostly Sunny</Weather>
    <Tlow>18.3℃</Tlow>
    <Thigh>28.3℃</Thigh>
  </Weather>
  <Weather>
    <Date>2012年05月03日</Date>
    <Week>星期四(Thu)</Week>
    <Weather>Mostly Cloudy</Weather>
    <Tlow>18.9℃</Tlow>
    <Thigh>28.3℃</Thigh>
  </Weather>
</NewDataSet>

解决方案 »

  1.   

    Xmldocument
    http://msdn.microsoft.com/zh-cn/library/system.xml.xmldocument.aspx
    或者用
    Linq to Xml
    http://topic.csdn.net/u/20120421/20/7c878b85-9f8f-4bfb-b66a-232d9db421b7.html
      

  2.   

    既然是dataset,那么可以直接获取啊。
      

  3.   

            /// <summary>
            /// 获取指定节点的值
            /// </summary>
            /// <param name="strFileName">文件路径</param>
            /// <param name="nodeName">节点名称</param>
            /// <param name="value">设置后的值</param>
            /// <param name="nodeDir">指定节点所在的节点目录</param>
            /// <returns></returns>
            public static string GetNodeValue(string strFileName, string nodeName, string nodeDir)
            {
                string value = null;
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(strFileName);                XmlNodeList nodeList = xmlDoc.SelectSingleNode(nodeDir).ChildNodes;//获取bookstore节点的所有子节点                 foreach (XmlNode xn in nodeList)    //遍历所有子节点 
                    {
                        XmlElement xe = (XmlElement)xn;  //将子节点类型转换为XmlElement类型                     if (xe.Name == nodeName)
                        {
                            value = xe.InnerText.Trim();                        break;
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw exp;
                }            return value;
            }        /// <summary>
            /// 获取指定节点下面对应属性的值
            /// </summary>
            /// <param name="strFileName">文件路径</param>
            /// <param name="nodeName">节点名称</param>
            /// <param name="nodeDir">指定节点所在的节点目录</param>
            /// <param name="attribute">节点对应的属性名称</param>
            /// <returns></returns>
            public static string GetNodeValue(string strFileName, string nodeName, string nodeDir, string attribute)
            {
                string value = null;
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(strFileName);                XmlNodeList nodeList = xmlDoc.SelectSingleNode(nodeDir).ChildNodes;//获取bookstore节点的所有子节点                 foreach (XmlNode xn in nodeList)    //遍历所有子节点 
                    {
                        XmlElement xe = (XmlElement)xn;  //将子节点类型转换为XmlElement类型                     if (xe.Name == nodeName)
                        {
                            //value = xe.InnerText.Trim();
                            value = (xe).Attributes[attribute].Value;
                            break;
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw exp;
                }            return value;
            }
      

  4.   

    直接操作XML 或者用Linq来查询。代码网上查下就行
      

  5.   

    请参考链接:在 DataSet 中使用 XML
      

  6.   

    我试过了这样写:
    string s=Convert.ToString(result.Tables[tableName].Rows[0][0]);提示错误:未将对象引用设置到对象的实例。 不知道哪里错了
      

  7.   


     protected void Page_Load(object sender, EventArgs e)
            {
                string serverpath = Server.MapPath("test1.xml");
                Response.Write(GetNodeValue(serverpath, "Weather", "NewDataSet"));
            }        public static string GetNodeValue(string strFileName,string nodeName,string nodeDir)
            {
                string value = null;
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(strFileName);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode(nodeDir).ChildNodes;
                    int i = 1;
                    foreach (XmlNode xn in nodeList)
                    {
                        value += i.ToString() + "<br/>";
                        XmlElement xe = (XmlElement)xn;
                        if (xe.Name == nodeName)
                        {
                            for (int j = 0; j < 5; j++)
                            {
                                value += xe.ChildNodes[j].InnerText + "<br/>";
                            }                    
                        }
                        i++;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return value;
            }
    稍微做了点调整,上面的方法能直接用
      

  8.   

    Dataset ds=new Dataset();
    Ds.readxml("文件路径");
    之后看你那的ds 中包含几张表一般情况下 xml中节点的值是一dataset中 Datatable 行列!