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 / September 2004

Tip: Looking for answers? Try searching our database.

Writing the Xml Declaration Using XmlDocument

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan - 21 Sep 2004 12:35 GMT
 Is there a better way to include the XML declaration than the following?

           XmlDeclaration dec
=m_XMLDocument.CreateXmlDeclaration("1.0",string.Empty, "yes");
           m_XMLDocument.InsertBefore((XmlNode)dec,
(XmlNode)m_XMLDocument.DocumentElement);
           XmlTextWriter writer = new
XmlTextWriter(m_FileName,Encoding.Default);
           writer.WriteRaw(m_XMLDocument.OuterXml);
           writer.Flush();
           writer.Close();
Christoph Schittko [MVP] - 21 Sep 2004 14:00 GMT
No, there is no better way to add an Xml document declaration to an
XmlDocument object.

What are you looking for?

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

> -----Original Message-----
> From: Dan [mailto:dan@dontspamme.com]
[quoted text clipped - 14 lines]
>             writer.Flush();
>             writer.Close();
Dan - 21 Sep 2004 14:38 GMT
Re: Writing the Xml Declaration Using XmlDocumentI was curious if someone would say that the preferred way is to use XmlDocument.WriteTo, passing the TextWriter as an argument.  Or does it just not make a difference?

 No, there is no better way to add an Xml document declaration to an XmlDocument object.

 What are you looking for?

 HTH,
 Christoph Schittko
 MVP XML
 http://weblogs.asp.net/cschittko

 > -----Original Message-----
 > From: Dan [mailto:dan@dontspamme.com]
 > Posted At: Tuesday, September 21, 2004 6:36 AM
 > Posted To: microsoft.public.dotnet.xml
 > Conversation: Writing the Xml Declaration Using XmlDocument
 > Subject: Writing the Xml Declaration Using XmlDocument
 >
 >   Is there a better way to include the XML declaration than the following?
 >
 >             XmlDeclaration dec
 > =m_XMLDocument.CreateXmlDeclaration("1.0",string.Empty, "yes");
 >             m_XMLDocument.InsertBefore((XmlNode)dec,
 > (XmlNode)m_XMLDocument.DocumentElement);
 >             XmlTextWriter writer = new
 > XmlTextWriter(m_FileName,Encoding.Default);
 >             writer.WriteRaw(m_XMLDocument.OuterXml);
 >             writer.Flush();
 >             writer.Close();
Christoph Schittko [MVP] - 22 Sep 2004 02:54 GMT
Dan,



I was primarily answering your question on how to get the document
declaration into an XmlDocument object. If the object is to get it into
the output file, then why not do:



XmlTextWriter writer = new XmlTextWriter(m_FileName,Encoding.Default);

writer.WriteStartDocument();

m_XMLDocument.WriteTo( writer );



Christoph









 _____  

From: Dan [mailto:dan@dontspamme.com]
Posted At: Tuesday, September 21, 2004 8:38 AM
Posted To: microsoft.public.dotnet.xml
Conversation: Writing the Xml Declaration Using XmlDocument
Subject: Re: Writing the Xml Declaration Using XmlDocument
 

I was curious if someone would say that the preferred way is to use
XmlDocument.WriteTo, passing the TextWriter as an argument.  Or does it
just not make a difference?



No, there is no better way to add an Xml document declaration to an
XmlDocument object.

What are you looking for?

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

> -----Original Message-----
> From: Dan [mailto:dan@dontspamme.com]
[quoted text clipped - 14 lines]
>             writer.Flush();
>             writer.Close();

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.