Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 11, 2012 11:16 PM by DanRowe
Member
62 Points
48 Posts
Apr 11, 2012 07:48 PM|LINK
I need to have an element that looks like this:
<dateOfBirth format="MMDDCCYY">01011989</dateOfBirth>
In an XML. I am using the XMLWriter class to create the file.
I have added attributes on start/End elements so it looks like this:
<userId>User1</userId>
<applicants Version="1">
<applicant type="Applicant 1"> <name> <first>Mary</first> <last>Leftus</last> </name> </applicant> </applicants>
But cant seem to get this.
All-Star
26445 Points
4389 Posts
Apr 11, 2012 08:44 PM|LINK
Just a shot in the dark - but give this a try:
//Placed right after ending the Name Element xmlWriter.WriteStartElement("dateOfBirth"); xmlWriter.WriteAttributeString("format","MMDDCCYY"); xmlWriter.WriteString(yourBirthDateValue); xmlWriter.WriteEndElement();
Source
Apr 11, 2012 11:16 PM|LINK
that did it thanks
DanRowe
Member
62 Points
48 Posts
How to add element and attribute on one line
Apr 11, 2012 07:48 PM|LINK
I need to have an element that looks like this:
<dateOfBirth format="MMDDCCYY">01011989</dateOfBirth>
In an XML. I am using the XMLWriter class to create the file.
I have added attributes on start/End elements so it looks like this:
<userId>User1</userId>
<applicants Version="1">
<applicant type="Applicant 1"> <name> <first>Mary</first> <last>Leftus</last> </name> </applicant> </applicants>But cant seem to get this.
Rion William...
All-Star
26445 Points
4389 Posts
Re: How to add element and attribute on one line
Apr 11, 2012 08:44 PM|LINK
Just a shot in the dark - but give this a try:
//Placed right after ending the Name Element xmlWriter.WriteStartElement("dateOfBirth"); xmlWriter.WriteAttributeString("format","MMDDCCYY"); xmlWriter.WriteString(yourBirthDateValue); xmlWriter.WriteEndElement();Source
DanRowe
Member
62 Points
48 Posts
Re: How to add element and attribute on one line
Apr 11, 2012 11:16 PM|LINK
that did it thanks