I need help in writing a datatable as xml in an aspx page. I have an
excel client that opens the response as a stream into a recordset. In
converting this code to .net c# from asp vb (where is used an
adodb.stream, I can't seem to get the output right. I've tried the a
gazillion methods, using memorystream, xmltextwriter, xmldatadoc, etc.
all returning invalid xml (see below). What i need is xml that looks
like the code at the end of this post - thanks for your help!
<!-- for example - this: //-->
StringWriter sw = new StringWriter();
dt.DataSet.WriteXml(sw,XmlWriteMode.WriteSchema);
string s = sw.ToString();
Response.Write("<?xml version='1.0' ?>");
Response.Write(s);
<!-- returns this: //-->
<?xml version="1.0" ?>
- <NewDataSet>
- <xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true">
- <xs:complexType>
- <xs:choice maxOccurs="unbounded">
- <xs:element name="Table">
- <xs:complexType>
- <xs:sequence>
<xs:element name="VAR_VALUE" type="xs:string" minOccurs="0" />
<xs:element name="VAR_KEY" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
- <Table>
<VAR_VALUE>LSUS</VAR_VALUE>
<VAR_KEY>DIVISION</VAR_KEY>
</Table>
- <Table>
<VAR_VALUE>DB2T</VAR_VALUE>
<VAR_KEY>x</VAR_KEY>
</Table>
- <Table>
<VAR_VALUE>TRUE</VAR_VALUE>
<VAR_KEY>Y</VAR_KEY>
</Table>
</NewDataSet>
<!-- I need this: //-->
<?xml version='1.0' ?>
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly'>
<s:AttributeType name='VAR_VALUE' rs:number='1'
s:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str'
dt:maxLength='200'/>
</s:AttributeType>
<s:AttributeType name='VAR_KEY' rs:number='2'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str'
dt:maxLength='10'
rs:maybenull='false'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row VAR_VALUE='LSUS' VAR_KEY='DIVISION'/>
<z:row VAR_VALUE='DB2P' VAR_KEY='DB2DSN'/>
<z:row VAR_VALUE='TRUE' VAR_KEY='PRODPROF'/>
</rs:data>
</xml> 1 4482
Try giving the duplicate elements different names. I seems to get lost..
I had this problem before also.
Schneider
"jk" <jk******@levi.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... I need help in writing a datatable as xml in an aspx page. I have an excel client that opens the response as a stream into a recordset. In converting this code to .net c# from asp vb (where is used an adodb.stream, I can't seem to get the output right. I've tried the a gazillion methods, using memorystream, xmltextwriter, xmldatadoc, etc. all returning invalid xml (see below). What i need is xml that looks like the code at the end of this post - thanks for your help!
<!-- for example - this: //-->
StringWriter sw = new StringWriter(); dt.DataSet.WriteXml(sw,XmlWriteMode.WriteSchema); string s = sw.ToString(); Response.Write("<?xml version='1.0' ?>"); Response.Write(s);
<!-- returns this: //-->
<?xml version="1.0" ?> - <NewDataSet> - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> - <xs:element name="NewDataSet" msdata:IsDataSet="true"> - <xs:complexType> - <xs:choice maxOccurs="unbounded"> - <xs:element name="Table"> - <xs:complexType> - <xs:sequence> <xs:element name="VAR_VALUE" type="xs:string" minOccurs="0" /> <xs:element name="VAR_KEY" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> - <Table> <VAR_VALUE>LSUS</VAR_VALUE> <VAR_KEY>DIVISION</VAR_KEY> </Table> - <Table> <VAR_VALUE>DB2T</VAR_VALUE> <VAR_KEY>x</VAR_KEY> </Table> - <Table> <VAR_VALUE>TRUE</VAR_VALUE> <VAR_KEY>Y</VAR_KEY> </Table> </NewDataSet>
<!-- I need this: //-->
<?xml version='1.0' ?> <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <s:Schema id='RowsetSchema'> <s:ElementType name='row' content='eltOnly'> <s:AttributeType name='VAR_VALUE' rs:number='1' s:nullable='true' rs:writeunknown='true'> <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='200'/> </s:AttributeType> <s:AttributeType name='VAR_KEY' rs:number='2' rs:writeunknown='true'> <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/> </s:AttributeType> <s:extends type='rs:rowbase'/> </s:ElementType> </s:Schema> <rs:data> <z:row VAR_VALUE='LSUS' VAR_KEY='DIVISION'/> <z:row VAR_VALUE='DB2P' VAR_KEY='DB2DSN'/> <z:row VAR_VALUE='TRUE' VAR_KEY='PRODPROF'/> </rs:data> </xml> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon |
last post by:
Hi all,
I have a process, where I take a dataset from an SQL call, and need to write
an XML file from that dataset.
The data set can contain 10's of tables, each with 100's of rows, and I have...
|
by: RichW |
last post by:
I've seen a couple other posts on this but no real answers. I'm
trying to do a bulk insert and everything is fine until I run the
objCom.ExecuteNonQuery() statement at which point I get the XML...
|
by: Andreas Palm |
last post by:
I have a dataset that has DBNull in certain columns, now when I write
out this one to XML, I only get the columns as elements that do have
data in it. However I do need also the empty colums as...
|
by: Dave |
last post by:
Hi all,
I've seen that many people have had this exact same problem in the past, but
no-one seems to post the answer when (if) they solve it... so here we go
again.
If I create a strongly...
|
by: Joe98765 |
last post by:
I have data coming from SQL Server and need to write out some XML. I
have a schema(xsd) for this XML file. Right now I am bringing in the
DataSet and writing out the elements and attributes myself...
|
by: Wes |
last post by:
Hello,
I have an application using an xml dataset to store app and user settings.
The problem I am having is related to writexml. I have a save button on my
application that updates the dataset...
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only...
|
by: David Richards |
last post by:
Hi,
I was wondering if anyone could help me. I have DataSet that contains
the following data tables Customers, Calls, Quotes, QuoteDetails,
Competitors, Contacts, Notes, and I have setup...
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml
method.
If I say XmlWriteMode.IgnoreSchema, it shows up great in Excel, but I can
not reopen the file in my...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |