PC Review


Reply
 
 
Guest
Posts: n/a
 
      26th Nov 2007
Hi how to add <?xml version ="1.0" encoding="UTF-8" ?> to my xml below?
Please help.

Code:
XmlDocument xmlDom = new XmlDocument ();
xmlDom.AppendChild(xmlDom.CreateElement ("", "Request", ""));
XmlElement xmlRoot = xmlDom.DocumentElement;
XmlElement xmlBook;
XmlElement xmlTitle, xmlAuthor, xmlPrice;
XmlText xmlText;


 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      26th Nov 2007
How are you displaying the XML?

If you were creating an XmlWriter, for example, and you set the
OmitXmlDeclaration property to true, it would omit this on output.

If you are calling ToString on XmlDocument (or InnerXml or something
like that), then it won't be there.

My recommendation is to create an XmlWriter with a StringWriter as the
backing store, and then save the xml to that XmlWriter (making sure that
OmitXmlDeclaration is false). Then you can use that string if you want to
display it, or you can just use a different TextWriter implementation to
store the result anywhere you want.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi how to add <?xml version ="1.0" encoding="UTF-8" ?> to my xml below?
> Please help.
>
> Code:
> XmlDocument xmlDom = new XmlDocument ();
> xmlDom.AppendChild(xmlDom.CreateElement ("", "Request", ""));
> XmlElement xmlRoot = xmlDom.DocumentElement;
> XmlElement xmlBook;
> XmlElement xmlTitle, xmlAuthor, xmlPrice;
> XmlText xmlText;
>
>



 
Reply With Quote
 
Tom Porterfield
Guest
Posts: n/a
 
      26th Nov 2007
(E-Mail Removed) wrote:
> Hi how to add <?xml version ="1.0" encoding="UTF-8" ?> to my xml below?
> Please help.
>
> Code:
> XmlDocument xmlDom = new XmlDocument ();
> xmlDom.AppendChild(xmlDom.CreateElement ("", "Request", ""));
> XmlElement xmlRoot = xmlDom.DocumentElement;
> XmlElement xmlBook;
> XmlElement xmlTitle, xmlAuthor, xmlPrice;
> XmlText xmlText;


As Nicholas said you can use the XmlWriter.

If you want to stick with using the XmlDocument, you can create the
declaration with the CreateXmlDeclaration method.

XmlDeclaration xdec = xmlDom.CreateXmlDeclaration("1.0", "UTF-8", null);
--
Tom Porterfield
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Freeze' Report Header and Page Header in screen view - possible? PamB Microsoft Access Reports 3 26th Apr 2010 04:44 AM
Header Problem (page header & report header) Eva Microsoft Access 2 23rd Oct 2009 03:46 PM
Pin header to Paralled, pin header to serial and pin header to USBadaptor questions Boo DIY PC 1 22nd Apr 2008 04:55 PM
subreport group header cut-off by main report page header dkingston Microsoft Access Reports 0 19th Apr 2004 09:27 PM
page header shows up in previous section where no header is wanted Keith Brickey Microsoft Word Document Management 0 29th Aug 2003 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 PM.