我不需要逐个输出的方式,有没有通过设置后,调用WRITEXML之类的方法直接生成的手段

解决方案 »

  1.   


    // Set the file path and name. Modify this for your purposes.
       string filename="mySchema.xml";
       // Create a FileStream object with the file path and name.
       System.IO.FileStream myFileStream = new System.IO.FileStream
          (filename,System.IO.FileMode.Create);
       // Create a new XmlTextWriter object with the FileStream.
       System.Xml.XmlTextWriter MyXmlTextWriter = 
          new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
       // Write the schema into the DataSet and close the reader.
       thisDataSet.WriteXmlSchema(MyXmlTextWriter );
       MyXmlTextWriter.Close();
      

  2.   

    这是不做处理调用WRITEXML方法的效果
    <Customers>
      <年份>2001</年份> 
      <建筑业>6462</建筑业> 
      </Customers>
    本人需要的效果是
    <Customers 年份=2001> 
      <建筑业>6462</建筑业> 
     </Customers>
    各位兄弟看清要求,请指教