471,610 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

URGENT: Formatting ADO style XML

Hi,

I am writing a windows form that will query the database.

string query = "SELECT TOP 2 * FROM Northwind.dbo.Customers" ;
DBQuery Q = new DBQuery() ;
bool result = dbCommander.RunQuery(query, true, ref Q) ;

if(result)
{
stream = new MemoryStream(Q.DataAsByteArray, false) ;
stream.Position = 0;
XmlTextReader xmlReader = new XmlTextReader(stream);

DataSet ds = new DataSet();
ds.ReadXml( xmlReader );

// does not give me anything...
Debug.WriteLine( ds.GetXml() );

xmlReader.Close() ;
}
Here is typically ADO style XML stream I recieve from the queries I send to
the database:

<xml version="1.0" encoding="UTF-16">
<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"
rs:CommandTimeout="30">
<s:AttributeType name="CustomerID" rs:number="1"
rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="5"
rs:fixedlength="true" rs:maybenull="false" />
</s:AttributeType>
<s:AttributeType name="CompanyName" rs:number="2"
rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="40"
rs:maybenull="false" />
</s:AttributeType>
<s:AttributeType name="ContactName" rs:number="3"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="30" />
</s:AttributeType>
<s:AttributeType name="ContactTitle" rs:number="4"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="30" />
</s:AttributeType>
<s:AttributeType name="Address" rs:number="5"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="60" />
</s:AttributeType>
<s:AttributeType name="City" rs:number="6"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="15" />
</s:AttributeType>
<s:AttributeType name="Region" rs:number="7"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="15" />
</s:AttributeType>
<s:AttributeType name="PostalCode" rs:number="8"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="10" />
</s:AttributeType>
<s:AttributeType name="Country" rs:number="9"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="15" />
</s:AttributeType>
<s:AttributeType name="Phone" rs:number="10"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="24" />
</s:AttributeType>
<s:AttributeType name="Fax" rs:number="11"
rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="24" />
</s:AttributeType>
<s:extends type="rs:rowbase" />
</s:ElementType>
</s:Schema>
<rs:data>
<z:row CustomerID="ALFKI" CompanyName="Alfreds Futterkiste"
ContactName="Maria Anders"
ContactTitle="Sales Representative" Address="Obere Str. 57"
City="Berlin" PostalCode="12209"
Country="Germany" Phone="030-0074321" Fax="030-0076545" />
<z:row CustomerID="ANATR" CompanyName="Ana Trujillo Emparedados
y helados" ContactName="Ana Trujillo"
ContactTitle="Owner" Address="Avda. de la Constitución 2222"
City="México D.F." PostalCode="05021"
Country="Mexico" Phone="(5) 555-4729" Fax="(5) 555-3745" />
</rs:data>
</xml>

I know I could use the XmlDocument but what I would like to achieve is
getting the DataSet table mapping of several tables which I do not think I
could achieve with XmlDocument (unless I am wrong)... As far as I personally
think I do not think the DataSet can handle this form of XML. I think I will
need to first parse it to a more likeable XML format the DataSet will be able
to recognize.

How could I parse the XML above to something a more common XML format?

Thanks,

~yamazed
Nov 12 '05 #1
1 1278
"Yama" <Ya**@discussions.microsoft.com> wrote in message news:6A**********************************@microsof t.com...
<xml version="1.0" encoding="UTF-16">
<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"> : : As far as I personally think I do not think the DataSet can handle
this form of XML.
Not directly, no.
How could I parse the XML above to something a more
common XML format?


You could write an XSLT stylesheet; or a custom XmlReader.

It's probably easier to load this legacy XML into an ADO Recordset
(using Interop) which understands it, and then use the SQLOLEDB
provider to import it into an ADO.NET DataSet as described in this
excellent knowledge base article,

http://support.microsoft.com/kb/315974
Derek Harmon
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dan Weeb | last post: by
2 posts views Thread by dinoo | last post: by
2 posts views Thread by John Mason | last post: by
4 posts views Thread by Arthur Dent | last post: by
25 posts views Thread by mdh | last post: by
5 posts views Thread by mrid via DotNetMonster.com | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.