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 / March 2008

Tip: Looking for answers? Try searching our database.

getting the xml from XmlTextWriter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SneakyMonki - 31 Mar 2008 17:04 GMT
We have an app that uses the XmlTextWriter to write XML to the local disk. It
works and it's great. Now they want to write it to the database instead. Is
there a way that I can just get the XML out of the XmlTextWriter? I looked at
the XmlTextWriter class and can't seem to figure out how to take the XML out
of it. I want to do this

dim x as string
x = XmlTextWriter.XML

Thanks in advance, Rob
Bjoern Hoehrmann - 31 Mar 2008 17:12 GMT
* SneakyMonki wrote in microsoft.public.dotnet.xml:
>We have an app that uses the XmlTextWriter to write XML to the local disk. It
>works and it's great. Now they want to write it to the database instead. Is
>there a way that I can just get the XML out of the XmlTextWriter? I looked at
>the XmlTextWriter class and can't seem to figure out how to take the XML out
>of it.

Instead of writing to a file, write to a MemoryStream or equivalent. The
Writer does not buffer the generated XML code, so that is the only way.
Signature

Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

Alex Meleta - 31 Mar 2008 17:14 GMT
Hi SneakyMonki,

You can do it by writing to the other buffer.
StringBuilder output = new StringBuilder();
XmlTextWriter writer =  new XmlTextWriter(new StringWriter(output));

output,ToString() will contain your text then

Regards,
Alex Meleta
[Tech Blog: http://devkids.blogspot.com]

S> We have an app that uses the XmlTextWriter to write XML to the local
S> disk. It works and it's great. Now they want to write it to the
S> database instead. Is there a way that I can just get the XML out of
S> the XmlTextWriter? I looked at the XmlTextWriter class and can't seem
S> to figure out how to take the XML out of it. I want to do this
S>
S> dim x as string
S> x = XmlTextWriter.XML
S> Thanks in advance, Rob
S>
Bjoern Hoehrmann - 31 Mar 2008 18:36 GMT
* Alex Meleta wrote in microsoft.public.dotnet.xml:
>You can do it by writing to the other buffer.
>StringBuilder output = new StringBuilder();
>XmlTextWriter writer =  new XmlTextWriter(new StringWriter(output));

You need to pay special attention to character encoding issues in
that case though, like correcting the XML declaration as necessary.
Signature

Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


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.