4种读取xml文件方法

    技术2025-09-05  86

    DataSet ds=new DataSet();System.IO.FileStream fs=new System.IO.FileStream("abc.xml",System.IO.FileMode.Open);//读取XML文档ds.ReadXmlSchema(fs);fs.Close();2,使用文件名的例子:DataSet ds=new DataSet();ds.ReadXmlSchema("abc.xml");3,使用StreamReader对象(TextReader的派生类)DataSet ds=new DataSet();System.IO.StreamReader sr=new System.IO.StreamReader("abc.xml");sr.Close();4,使用XmlTextReader(XmlReader的派生类)DataSet ds=new DataSet();System.IO.FileStream fs=new System.IO.FileStream("abc.xml",System.IO.FileMode.Open);System.Xml.XmlTextReader xmlreader=new System.Xml.XmlTextReader(fs);ds.ReadXmlSchema(xmlreader);xmlreader.Close();

    原文来自:http://www.04js.cn/content.asp?id=1336

    最新回复(0)