请问各位仁兄
      怎么在程序中读取XML文件对象的内容,文件对象是动态创建的,不能保存?

解决方案 »

  1.   

    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
    doc.LoadXml(StringXml);
    然后再解析doc里的内容
      

  2.   

    XmlDocument xml=new XmlDocument();
                xml.Load(HttpContext.Current.Server.MapPath("performance.xml"));
                XmlNode root=xml.SelectSingleNode("/root");
                XmlNode leaf;
                for(int i=0;i<root.ChildNodes.Count;i++)
                {
                    leaf=root.ChildNodes[i];
                    if(leaf.Attributes["name"].Value=="AB类客户保有率")
                    {
                        leaf=leaf.FirstChild;
                        leaf.InnerText=txtRe.Text;
                        break;
                    }
                }
                xml.Save(HttpContext.Current.Server.MapPath("performance.xml"));7in10
      

  3.   

    DataSet theDS = new DataSet();
    theDS.ReadXML("XML文件路径");
    XML的结构和内容就被读取到DataSet里了  每一层就是一个DataTabel
    要写出文件就是 theDS.WriteXML("XML文件路径");
      

  4.   

    把你要傳的資料寫成XML格式的字串Param
    XmlDocument x = new XmlDocument();
    x.LoadXml(Param);
    這樣就可以應用了

    x.SelectSingleNode("//MSI_MPS_WARNING/MPS_VERSION").InnerText.ToString()
    樣式
      

  5.   

    DataSet theDS = new DataSet();
    theDS.ReadXML("XML文件路径");
      

  6.   

    我是创建了一个动态的XML文件,需要把文件的文本保存到数据库里,但现在得不到整个文件的文本,程序规定不能保存为XML文件.
      

  7.   

    using System;
    using System.Data;
    using System.IO;
    using System.Xml;
    DataSet myDataSet=new DataSet();
    FileStream fsReadXml=new FileStream(myFilename,FileMode.Open);
    XmlTextReader myXmlReader=new XmlTextReader(fsReadXml);
    myDataSet.ReadXml(myXmlReader);
    myXmlReader.Close();
    //提出当前选票的个数的字符
    string votes=myDataSet.Tables[1].Rows[answer-1].ItemArray[1].ToString();
    int votesInt=int.Parse(votes);//转化为整数
    //int votesInt=Votes[answer];
    DataRow myVotesRow=myDataSet.Tables[1].Rows[answer-1];//提取当前操作行
    myVotesRow["Votes"]=(votesInt+1).ToString();//修改
    StreamWriter myStream=new StreamWriter(myFilename);//建立写流
    myDataSet.WriteXml(myStream,XmlWriteMode.IgnoreSchema);//保存文件
    myStream.Close();
      

  8.   

    取得一个DATASET中的XML内容
    DataSet ds = new DataSet();
    ...
    string strTxt=ds.GetXml();
      

  9.   

    是的,楼主是动态创建的,所以不是打开XML文件System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
    doc.LoadXml(你动态创建的类XML结构字符串);或doc.LoadXml(你动态创建的流);
      

  10.   

    解决了,用innerXml 就可以了