-
writing XML Confusion...
Do any of you guys/girls out there know how to rewrite this code to work with the xmlTextWriter class? I need to re-create a document similar to this but preserve the formatting. Any help or ideas would be much appreciated. Thanks in Advance. 
Dim sw As New StreamWriter(New FileStream("Results.xml", FileMode.Create))
Dim xmltw As New XmlTextWriter(sw)
Dim reader As XmlTextReader = New XmlTextReader("books.xml")
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element 'Display beginning of element.
Console.Write("<" + reader.Name)
If reader.HasAttributes Then 'If attributes exist
While reader.MoveToNextAttribute()
'Display attribute name and value.
Console.Write(" {0}='{1}'", reader.Name, reader.Value)
End While
End If
Console.WriteLine(">")
Case XmlNodeType.Text 'Display the text in each element.
Console.WriteLine(reader.Value)
Case XmlNodeType.EndElement 'Display end of element.
Console.Write("</" + reader.Name)
Console.WriteLine(">")
End Select
Loop
Console.ReadLine()
End SubI know i need to use the methods like writeStartElemnt, writeElementString, writeAttributeString, etc.
I'm just confused as to where to use what.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks