Reading XML
-
I orginally posted this in the C# forum as I did not notice there was a xml forum... :-D I am trying to read an xml file into a dataset and have been met with nothing but problems. The xml file is in the following format:
<?xml version="1.0"?> <Catalog xmlns:dt="dt"> <Rec> <ITEM dt:dt="string"></ITEM> <QTY dt:dt="string">1</QTY> <SUB dt:dt="string"></SUB> <CATALOG dt:dt="string">ABC123</CATALOG> </Rec> </Catalog>
I have tried this code in C#:Dataset ds = new DataSet("Test"); ds.ReadXML(OFD.FileName);
When I set a breakpoint just after this code and examine ds, all have is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!! Someone else has tried this and gets finds that ds has changed from "Test" to "Catalog", which is believed to have been picked up from the xml file. Expanding the Tables node reveals have 5 tables: [0] Rec [1] ITEM [2] QTY [3] SUB [4] CATALOG I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!! If I remove thedt:dt="String"
datatypes then everything is fine. I do not want to manually do this so if this is the only way then how can I do it programatically? I need an automated solution. Can anyone help? Thanks -
I orginally posted this in the C# forum as I did not notice there was a xml forum... :-D I am trying to read an xml file into a dataset and have been met with nothing but problems. The xml file is in the following format:
<?xml version="1.0"?> <Catalog xmlns:dt="dt"> <Rec> <ITEM dt:dt="string"></ITEM> <QTY dt:dt="string">1</QTY> <SUB dt:dt="string"></SUB> <CATALOG dt:dt="string">ABC123</CATALOG> </Rec> </Catalog>
I have tried this code in C#:Dataset ds = new DataSet("Test"); ds.ReadXML(OFD.FileName);
When I set a breakpoint just after this code and examine ds, all have is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!! Someone else has tried this and gets finds that ds has changed from "Test" to "Catalog", which is believed to have been picked up from the xml file. Expanding the Tables node reveals have 5 tables: [0] Rec [1] ITEM [2] QTY [3] SUB [4] CATALOG I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!! If I remove thedt:dt="String"
datatypes then everything is fine. I do not want to manually do this so if this is the only way then how can I do it programatically? I need an automated solution. Can anyone help? Thanks