I want to be able to extract all of the TEXT from the XML file and put it line by line into a rtf file.Code:XML: <xxx>TEXT</xxx>
So far my code wirtes all of the attributes of the elements to the file but I dont know how to loop through it so it only writes the text values.
(I've blocked out the message boxes and other code with comments just to see what out put I got.)
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim reader As XmlTextReader = New XmlTextReader("c:\msn2.xml") Dim fs As FileStream = New FileStream("C:\out.rtf", FileMode.OpenOrCreate) Dim w As BinaryWriter = New BinaryWriter(fs) Do While (reader.Read()) Select Case (reader.NodeType) 'Case XmlNodeType.DocumentType 'w.Write("Found Document Type: " + reader.Name + " which contains: " + reader.Value + vbCrLf + vbCrLf) 'MsgBox("Found Document Type: " + reader.Name + " which contains: " + reader.Value) Case XmlNodeType.Text w.Write(reader.Value + vbCrLf + vbCrLf) 'MsgBox("Text: " + reader.Value) Case XmlNodeType.Element 'w.Write("Found Element = " + reader.Name + vbCrLf + vbCrLf) 'MsgBox("Found Element = " + reader.Name) While (reader.MoveToNextAttribute()) 'w.Write("The name of the attribute is: " + reader.Name + ",it contains: " + reader.Value + vbCrLf + vbCrLf) 'MsgBox("The name of the attribute is: " + reader.Name + ",it contains: " + reader.Value) End While End Select Loop MsgBox("Finished!") fs.Close() End Sub End Class


Reply With Quote