PC Review


Reply
Thread Tools Rate Thread

ADO.NET Dataset to XML and displaying namespace

 
 
Simeon Lobo
Guest
Posts: n/a
 
      18th Jan 2005
Hello All,

I have an ASP.NET web form that retrieves data from a SQL
Server stored proc containing a "FOR XML AUTO, XMLDATA".
The following is a snippet I use to convert the dataset to
XML;

'-- Start ---
ds.ReadXml(dr, XmlReadMode.Fragment)
Response.ContentType = "text/xml"
Response.Write(ds.GetXml)
'-- End ---

When the XML data is returned, it is formatted as;
<Schema1>
....
....
....
</Schema>

I was wondering if anyone could give me some ideas as to
replacing <Schema1> with a parent node of my choice. I
would also like to include a namespace declaration within
this parent node.

I would appreciate any ideas...thanks....

Simeon





 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3F1aWdncw==?=
Guest
Posts: n/a
 
      18th Jan 2005
You can associate a schema with your query. The Schema header will set the
root node such as the "myroot" in the partial schema header below:

<xsd:schema id="myRoot" xmlns:xsd="http://www.w3.org/2001/XMLSchema"...

If you don't have control over the schema used for the query then a simple
replace could be used (or XSLT transform).

ds.ReadXml(dr, XmlReadMode.Fragment)
dim s as string
s = ds.GetXml
s = s.Replace("<Schema1>","<myRoot>")
s = s.Replace("</Schema1>","</myRoot>")
Response.Write(s)

Hope this helps...

"Simeon Lobo" wrote:

> Hello All,
>
> I have an ASP.NET web form that retrieves data from a SQL
> Server stored proc containing a "FOR XML AUTO, XMLDATA".
> The following is a snippet I use to convert the dataset to
> XML;
>
> '-- Start ---
> ds.ReadXml(dr, XmlReadMode.Fragment)
> Response.ContentType = "text/xml"
> Response.Write(ds.GetXml)
> '-- End ---
>
> When the XML data is returned, it is formatted as;
> <Schema1>
> ....
> ....
> ....
> </Schema>
>
> I was wondering if anyone could give me some ideas as to
> replacing <Schema1> with a parent node of my choice. I
> would also like to include a namespace declaration within
> this parent node.
>
> I would appreciate any ideas...thanks....
>
> Simeon
>
>
>
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Namespace of typed DataSet? Rainer Queck Microsoft C# .NET 9 18th May 2010 01:04 PM
Is DataSet belong another namespace ad Microsoft C# .NET 2 18th Sep 2005 08:34 AM
Namespace and dataset Vik Microsoft ASP .NET 0 1st Feb 2005 05:37 PM
DataSet.ReadXmlSchema() changes namespace prefix David Elliott Microsoft Dot NET Framework 5 21st Jun 2004 09:33 AM
Usercontrol accessing Typed Dataset in root namespace k Microsoft Dot NET Framework Forms 0 23rd Aug 2003 10:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:32 AM.