Getting all contents from XMLReader into string?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SamIAm

    Getting all contents from XMLReader into string?

    Is there a way to do this without looping through all the nodes using read()

    I need to return the contents of the reader as a string

    Thanks

    S


  • Greg Merideth

    #2
    Re: Getting all contents from XMLReader into string?

    You can try something like

    StreamReader sr = new StreamReader(s) ;
    transForm.Load( new XmlTextReader(n ew StringReader(sr .ReadToEnd()))) ;

    Thats just a snippted to load in an .xsl file but you can use the same
    approach. Use .ReadToEnd() and pass that to your string to hold the data.

    XmlDocument.Loa d simply loads in the entire XML file into memory which
    then you can convert .ToString() as well.



    SamIAm wrote:
    [color=blue]
    > Is there a way to do this without looping through all the nodes using read()
    >
    > I need to return the contents of the reader as a string
    >
    > Thanks
    >
    > S
    >
    >[/color]

    Comment

    Working...