Connecting Tech Pros Worldwide Help | Site Map

How to create this with XmlTextWriter

  #1  
Old November 9th, 2006, 02:35 AM
Terry Olsen
Guest
 
Posts: n/a
Is this even possible using XmlTextWriter? Or would I need to use an
XmlDocument?

I need to create the following XML:

<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>
<Password>YOURPASSWORD</Password>
</AccessRequest>


When I use the XmlTextWriter, I always get this as the first line:
<?xml version="1.0" encoding="utf-16"?>

I also need help adding the: xml:lang="en-US" to the AccessRequest element.

Thanks a bunch!


  #2  
Old November 9th, 2006, 02:35 AM
Terry Olsen
Guest
 
Posts: n/a

re: How to create this with XmlTextWriter


Actually, I figured out how to do the xml:lang attribute. Now how do I get
rid of the encoding attribute in the first line?

"Terry Olsen" <tolsen64@hotmail.comwrote in message
news:OcYBem6AHHA.4592@TK2MSFTNGP03.phx.gbl...
Quote:
Is this even possible using XmlTextWriter? Or would I need to use an
XmlDocument?
>
I need to create the following XML:
>
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>
<Password>YOURPASSWORD</Password>
</AccessRequest>
>
>
When I use the XmlTextWriter, I always get this as the first line:
<?xml version="1.0" encoding="utf-16"?>
>
I also need help adding the: xml:lang="en-US" to the AccessRequest
element.
>
Thanks a bunch!
>

  #3  
Old November 9th, 2006, 10:45 AM
Oleg Tkachenko [MVP]
Guest
 
Posts: n/a

re: How to create this with XmlTextWriter


Terry Olsen wrote:
Quote:
Actually, I figured out how to do the xml:lang attribute. Now how do I get
rid of the encoding attribute in the first line?
You can set UTF-8, which is default XML encoding. You can also
completely get rid of XML declaration by not calling
WriteStartDocument() method.

--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping Datarows with XMLTEXTWRITER Mickey N answers 0 May 10th, 2006 04:19 AM
How to create element in namespace FabrizioSW@gmail.com answers 4 April 21st, 2006 07:25 PM
how to create xml files out of an xml file based on an element ALI-R answers 2 November 16th, 2005 05:26 PM
How to create an XML document with XmlTextWriter? Dave answers 3 November 12th, 2005 03:03 AM