Resolved xml element string attribute

madgoose

Member
Joined
Aug 20, 2009
Messages
5
Programming Experience
10+
Need to create this in xml.
VB.NET:
<username name="first.last">
	<email>first.last@mailserver.com</email>
</username>

xmlWriter.WriteStartElement("BM00_XSD05") 'Open the Main Parent Node

For i = 1 To UBound(Filearray)
Dim strname() As String = Split(Filearray(i), "@")
xmlWriter.WriteStartElement("username")
xmlWriter.WriteStartAttribute("name", strname(0))
xmlWriter.WriteEndAttribute()
xmlWriter.WriteElementString("email", Filearray(i)) 'The Child
xmlWriter.WriteEndElement() 'Close username parent Node

Next i
xmlWriter.WriteEndElement() 'Close Main parent Node
xmlWriter.Close() 'close the file
My question is how to write this line of the xml.
<username name="first.last">

Sample output
VB.NET:
<username d2p1:name="" xmlns:d2p1="james.ceklosky">
		<email>james.ceklosky@siemens.com	</email>
	</username>

Resolved after continuing to search forum.
VB.NET:
xmlWriter.WriteStartElement("username")
            xmlWriter.WriteStartAttribute("name") 'writes only "name"
            xmlWriter.WriteValue(strname(0))  'writes username
            xmlWriter.WriteEndAttribute()
            xmlWriter.WriteElementString("email", Filearray(i)) 'The Child 
            xmlWriter.WriteEndElement() 'Close username parent Node
 
Last edited:

Latest posts

Back
Top