XmlReader to an XML string and then return the string

XmlReader to an XML string and then return the string

Post by Geir Aamod » Tue, 17 Sep 2002 18:51:26



I have some XML data inside an XMLReader object in an WebService.

I would like to convert the data to an XML string before it is returned to
the calller.

Please give me hints and/or samples on how to do this.

Best regards,

Geir

 
 
 

XmlReader to an XML string and then return the string

Post by Balaji Ramakrishna » Tue, 17 Sep 2002 20:25:20


Hope this helps:
<code>
System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(xmlPath);
xr.MoveToContent();
string opXML = xr.ReadOuterXml();
</code>

Quote:> I have some XML data inside an XMLReader object in an WebService.

> I would like to convert the data to an XML string before it is returned to
> the calller.

> Please give me hints and/or samples on how to do this.

> Best regards,

> Geir


 
 
 

XmlReader to an XML string and then return the string

Post by Geir Aamod » Tue, 17 Sep 2002 21:12:14


Great, works perfect!

Thanks a lot Balaji!

Regards,

Geir


> Hope this helps:
> <code>
> System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(xmlPath);
> xr.MoveToContent();
> string opXML = xr.ReadOuterXml();
> </code>


> > I have some XML data inside an XMLReader object in an WebService.

> > I would like to convert the data to an XML string before it is returned
to
> > the calller.

> > Please give me hints and/or samples on how to do this.

> > Best regards,

> > Geir

 
 
 

XmlReader to an XML string and then return the string

Post by Geir Aamod » Wed, 18 Sep 2002 01:30:59


Second question:

How do I  retrieve all the "rows" from the reader at once?

When I use ReadOuterXml I just get one "row" of XML  data.

Regards,

Geir


> Hope this helps:
> <code>
> System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(xmlPath);
> xr.MoveToContent();
> string opXML = xr.ReadOuterXml();
> </code>


> > I have some XML data inside an XMLReader object in an WebService.

> > I would like to convert the data to an XML string before it is returned
to
> > the calller.

> > Please give me hints and/or samples on how to do this.

> > Best regards,

> > Geir

 
 
 

XmlReader to an XML string and then return the string

Post by Balaji Ramakrishna » Wed, 18 Sep 2002 20:16:56


See your "Is it no possible in .NET (Xmlreader to xml string)???"  thread
for a solution.


> Second question:

> How do I  retrieve all the "rows" from the reader at once?

> When I use ReadOuterXml I just get one "row" of XML  data.

> Regards,

> Geir



> > Hope this helps:
> > <code>
> > System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(xmlPath);
> > xr.MoveToContent();
> > string opXML = xr.ReadOuterXml();
> > </code>


> > > I have some XML data inside an XMLReader object in an WebService.

> > > I would like to convert the data to an XML string before it is
returned
> to
> > > the calller.

> > > Please give me hints and/or samples on how to do this.

> > > Best regards,

> > > Geir

 
 
 

1. Is it no possible in .NET (Xmlreader to xml string)???

After looking and searching around, I have still not found any way to solve
the following:

* I retrieve a couple of hundreds of rows fra SQL Server with
cmd.ExecuteXmlReader within an WebService I created

* I then have a XmlReader object, so far, so good

* This XmlReader object I would like to convert to an simple XML string
containing all the data from the SQL Server

* This string should be returned (as an xml string) back to the caller of my
WebService

It is as easy as this, but no luck... All the doc and samples are talking
about InnerXml and serializing it to file, etc etc etc

I just want an XML stringm using something like GetXml (or something
similar) without using an DataSet or 325 lines of code!!

Best regards,

Geir

2. IOCTL_NDIS_QUERY_GLOBAL_STATS and 802.11 OIDs

3. Getting XML document string out of XmlReader

4. Media Player

5. how can i select a string from a Table and return its value as a string?

6. Help: DAT Backup Problems

7. .ToLower() not returning a "string" object for a String

8. CFP 14th IEEE Symposium on Mass Storage Systems

9. How to i split a string by string not char[], using String.Split()

10. how do i return muliple stream objects into c# XML string?

11. Return XML string as an output in Web service

12. Returning Stored Procedure XML into string

13. How to convert the content of XmlReader to String