How to write this using XML TextWriter

Bilalq

Member
Joined
Jul 21, 2004
Messages
24
Programming Experience
3-5
Hello,
Can someone please tell me how I can write this using XML TextWriter.

HTML:
<Department ID="1">CS</Department>

Basically, the element has an atribute and a value.

Thanks in advance.

Bilal
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,469
Location
Norway
Programming Experience
10+
Can someone please tell me how I can write this using XML TextWriter.
VB.NET:
Dim writer As New Xml.XmlTextWriter("new.xml", System.Text.Encoding.Default)
writer.WriteStartElement("Department")
writer.WriteAttributeString("ID", "1")
writer.WriteString("CS")
writer.WriteEndElement()
writer.Close()
 
Top Bottom