c# - Issue with Xml and dataset -


this problem pretty simple, making dataset , trying save file using xmltextwriter

now when save dataset , attempt read read table names shows rows 0? seems writer not writing rows of table?

anyone know how can fix this?

public static dataset livedata = new dataset();      public static datatable players = new datatable("players");  public static void writeschemawithxmltextwriter()     {         // set file path , name. modify purposes.          string filename = "schema.xml";          // create filestream object file path , name.         system.io.filestream stream = new system.io.filestream(filename, system.io.filemode.create);          // create new xmltextwriter object filestream.         system.xml.xmltextwriter writer = new system.xml.xmltextwriter(stream, system.text.encoding.unicode);          // write schema dataset , close reader.         livedata.writexmlschema(writer);         writer.close();     }      public static void readschemafromxmltextreader()     {         // set file path , name. modify purposes.          string filename = "schema.xml";          // create filestream object file path , name.         system.io.filestream stream = new system.io.filestream(filename, system.io.filemode.open);          // create new xmltextreader object filestream.         system.xml.xmltextreader xmlreader = new system.xml.xmltextreader(stream);          // read schema dataset , close reader.         livedata.readxmlschema(xmlreader);         console.writeline("y: {0}", livedata.tables["players"].rows.count);         xmlreader.close();     } 

thank in advance :)

you writing schema, layout/structure of xml, rather actual content.

you need use dataset.writexml ...

https://msdn.microsoft.com/en-us/library/ms135426%28v=vs.110%29.aspx

... instead!


Comments