473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to create this with XmlTextWriter

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!
Nov 9 '06 #1
2 1727
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" <to******@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP03.phx.gbl...
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!

Nov 9 '06 #2
Terry Olsen wrote:
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
Nov 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: cnu | last post by:
Hi, I have to make a formatted (indented) xml file like this : <?xml version="1.0"?> <Message> <Parent index="0" length="6">123 <Child1 index="0,1" length="6">abcd</Child1> <Child2...
3
by: Dave | last post by:
Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not...
7
by: pintihar | last post by:
Hi, As a follow on from an earlier post I have another question about xslt. Is it possible to create the stylsheet programatically? Is this sensible? In the first phase I needed to map element...
1
by: Mike P | last post by:
I am trying to create a new file and write to it, but I keep getting the error 'cannot access the file because it is being used by another process'. Can anybody help me out? long lngNextNumber...
4
by: John Salerno | last post by:
I thought I might use the XML functions in C# to help me do some repetitive typing in an XHTML file, but I'm stuck. Here's what I have before I just stopped: void WriteXMLFile() { string path...
1
by: jschell | last post by:
The following two cases behave differently in Net 2.0. The Case_Create_StringWriter throws an exception while the Case_XmlTextWriter does not. Is there a problem with this code? Or is this a...
8
by: David Thielen | last post by:
Hi; I need to be able to create a single xml node in utf-8 and do it efficiently as this is called a lot (reason below). What is the best way to do this? I need to end up with a string like...
4
by: FabrizioSW | last post by:
Hi all i've to create a xml doc like this <?xml version="1.0" encoding="UTF-8"?> <Main xmlns:x="http://www.w3.org/1999/XML/xinclude"> <x:include href="one.xml"/> <x:include href="two.xml"/>...
4
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.