I am trying to create a datatable from an xml file, using the dataset readxml method. however i am struggling to define the schema correctly to properly interpret this file.
i think the problem lies with the nesting and the fact that the ColumnUid (which ideally should be the column name) is a value rather than an element.
the datatable it returns at the moment has this structure:[
and i hope to make it return like this:
is this possible by defining the correct schema to pass to readxml... or even at all?
I could potentially transpose the datatable after the initial readxml, using eaither linq or a loop but would prefer to avoid this
the xml is as follows (shortened example):
<?xml version="1.0" encoding="utf-16"?>
<DataTable Uid="dtDocRows">
<Rows>
<Row>
<Cells>
<Cell>
<ColumnUid>DocEntry</ColumnUid>
<Value>121496</Value>
</Cell>
<Cell>
<ColumnUid>DocNum</ColumnUid>
<Value>264803</Value>
</Cell>
<Cell>
<ColumnUid>LineNum</ColumnUid>
<Value>0</Value>
</Cell>
<Cell>
<ColumnUid>ItemCode</ColumnUid>
<Value>BENIGRAMST55060075L</Value>
</Cell>
<Cell>
<ColumnUid>Quantity</ColumnUid>
<Value>1.000000</Value>
</Cell>
</Cells>
</Row>
<Row>
<Cells>
<Cell>
<ColumnUid>DocEntry</ColumnUid>
<Value>121658</Value>
</Cell>
<Cell>
<ColumnUid>DocNum</ColumnUid>
<Value>264965</Value>
</Cell>
<Cell>
<ColumnUid>LineNum</ColumnUid>
<Value>0</Value>
</Cell>
<Cell>
<ColumnUid>ItemCode</ColumnUid>
<Value>PYCCHANT202575L</Value>
</Cell>
<Cell>
<ColumnUid>Quantity</ColumnUid>
<Value>1.000000</Value>
</Cell>
</Cells>
</Row>
and the c# function to return the datatable is this:
private DataTable getDotNetDataTable()
{
DataSet ds = new DataSet();
XDocument xdoc = XDocument.Parse(dtDocRows.SerializeAsXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_DataOnly));
xdoc.Save(@"C:\1\xml\test.xml");
ds.ReadXml(@"C:\1\xml\test.xml");
return ds.Tables.Item(4);
return dt;
}