Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / December 2003

Tip: Looking for answers? Try searching our database.

XMLreader to text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill H - 29 Dec 2003 16:07 GMT
How do I read the entire XML text from an XMLReader ?
I just want to retrieve the XML string from a SQL SP formatted as XML.  I assumed the ExecuteXMLReader was the best option.  So whats the most streamlined process of getting the XML into a string ?

Thanks
Bill
Oleg Tkachenko - 29 Dec 2003 17:06 GMT
> How do I read the entire XML text from an XMLReader ?
> I just want to retrieve the XML string from a SQL SP formatted as XML.  
> I assumed the ExecuteXMLReader was the best option.  So whats the most
> streamlined process of getting the XML into a string ?

If you don't care about comments and PIs outside root element, all you
need is to move reader to content and read outer XML:

r.MoveToContent();
Console.WriteLine(r.ReadOuterXml());

if you do care about that stuff at roto level, then you can use
something lik ethis:

StringWriter sw = new StringWriter();
XmlTextWriter w = new XmlTextWriter(sw);
while (r.Read())
    w.WriteNode(r, false);
w.Close();
r.Close();
Console.WriteLine(sw.ToString());

Signature

Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.