473,413 Members | 1,798 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,413 software developers and data experts.

xml format problem

Hi

I'm using the following code to create xml string:

Dim Doc As New System.Xml.XmlDocument
Dim newAtt As System.Xml.XmlAttribute

Dim dec As System.Xml.XmlDeclaration
dec = Doc.CreateXmlDeclaration("1.0", Nothing, Nothing)
dec.Encoding = "UTF-8"
Doc.AppendChild(dec)

Dim DocRoot As System.Xml.XmlElement = Doc.CreateElement("userlist")
newAtt = Doc.CreateAttribute("ACTION")
newAtt.Value = vAction
DocRoot.Attributes.Append(newAtt)

newAtt = Doc.CreateAttribute("VENDORNAME")
newAtt.Value = vVendorName
DocRoot.Attributes.Append(newAtt)
Doc.AppendChild(DocRoot)

Dim amouser As System.Xml.XmlNode = Doc.CreateElement("amouser")
newAtt = Doc.CreateAttribute("AMOAID")
newAtt.Value = vAMOAID
amouser.Attributes.Append(newAtt)

newAtt = Doc.CreateAttribute("VENDORUSERNAME")
newAtt.Value = vH2UserName
amouser.Attributes.Append(newAtt)

newAtt = Doc.CreateAttribute("AMOATOKEN")
newAtt.Value = vAMOAToken
amouser.Attributes.Append(newAtt)

DocRoot.AppendChild(amouser)

Dim xmlstring = Doc.OuterXml

The result looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<userlist ACTION="redirectuser" VENDORNAME="H2Digital">
<amouser AMOAID="bb224c2a-fe8a-4c3f-acf4-6c0986b8cf78"
VENDORUSERNAME="xr*****@hotmail.com"
AMOATOKEN="hx0gH6e8PvswEzaA8oXPoVIY/KvnbP2/" />
</userlist>
I need the result to look like this: with </amouserinstead of />

<?xml version="1.0" encoding="UTF-8"?>
<userlist ACTION="redirectuser" VENDORNAME="H2Digital">
<amouser AMOAID="bb224c2a-fe8a-4c3f-acf4-6c0986b8cf78"
VENDORUSERNAME="xr*****@hotmail.com"
AMOATOKEN="hx0gH6e8PvswEzaA8oXPoVIY/KvnbP2/" </amouser>
</userlist>

Does anyone know what I'm doing wrong here?
Thanks,
Cindy
Jun 27 '08 #1
2 1253
CindyH wrote:
Does anyone know what I'm doing wrong here?
Whether an empty element is serialized as
<foo/>
or
<foo />
or
<foo></foo>
does not make a difference. If you want to enforce
<foo></foo>
nevertheless then with the .NET framework's DOM implementation set
IsEmpty to false, see
http://msdn.microsoft.com/en-us/libr...t.isempty.aspx

So in your original example you need
amouser.IsEmpty = False

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
Ok - thanks

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eI**************@TK2MSFTNGP06.phx.gbl...
CindyH wrote:
>Does anyone know what I'm doing wrong here?

Whether an empty element is serialized as
<foo/>
or
<foo />
or
<foo></foo>
does not make a difference. If you want to enforce
<foo></foo>
nevertheless then with the .NET framework's DOM implementation set IsEmpty
to false, see
http://msdn.microsoft.com/en-us/libr...t.isempty.aspx

So in your original example you need
amouser.IsEmpty = False

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jun 27 '08 #3

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

Similar topics

2
by: Bernd Lambertz | last post by:
I have a problem with bcp and format files. We changed our databases from varchar to nvarchar to support unicode. No problems so fare with that. It is working fine. But now I need a format...
2
by: amith | last post by:
hi I have written javascript for comparing two dates in US format and finding out whether the start date is greater than the end date and vice versa. In this attempt i have instantiated the...
1
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime...
6
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
8
by: Ishbel Kargar | last post by:
Since upgrading from old laptop (Windows 98) to new laptop (Windows XP), my mail-merge letters are doing strange things with date formats. For instance, my reminder letter for lapsed subs carries...
1
by: Wayne Aprato | last post by:
I have a client who is running several Access 97 databases that I have written for them. They are about to upgrade to Access 2003. Is the default file format of Access 2003 still Access 2000 the...
5
by: Ataru Morooka | last post by:
Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone...
2
by: Pat | last post by:
Here is my problem that I am having with a current project. I went and backed up all my hard drives to DVD's. After backing up the drives, I used a batch file to get all the file names from the...
9
by: insomniux | last post by:
Hi, I am having a problem with formatting the default value of a date field. It has been discussed earlier in many topics, but still I cannot solve the problem. What's happening: I have various...
3
by: karthikla | last post by:
Hi Experts, Could you please help me on how to get access 2002 file format exactly while doing conversion from Access 97 file format by DBEngine.CompactDatabase() function? Code: Private...
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.