Connecting Tech Pros Worldwide Help | Site Map

How to create this with XmlTextWriter

Terry Olsen
Guest
 
Posts: n/a
#1: Nov 9 '06
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!


Terry Olsen
Guest
 
Posts: n/a
#2: Nov 9 '06

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!
>

Oleg Tkachenko [MVP]
Guest
 
Posts: n/a
#3: Nov 9 '06

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