Hello everybody,
I have an xml doc and I am trying to write the values from xml file to a tab
delimited text file. Currently, what I am doing is I am reading xml file
through XpathNavigaotr and manipulating all the nodes,elements and attributes
than I am writing those values to a text file using stream writer. Now coming
to my problem When I am writing data to the text file value of the last
record is getting truncated. My code sample for formatting the xml looks like
this
Private Sub Format(ByVal myXPathNavigator As XPathNavigator)
Dim strtemp As String = String.Empty
If Not (myXPathNavigator.HasChildren) Then
If (myXPathNavigator.NodeType = XPathNodeType.Text) Then
' Console.Write(myXPathNavigator.Value + Chr(9))
strtemp = myXPathNavigator.Value
writer.Write(strtemp + Chr(9))
ElseIf (myXPathNavigator.Name <> String.Empty) Then
' Console.WriteLine("<" & myXPathNavigator.Name & ">")
Else
'Console.WriteLine()
End If
Else
'; Console.WriteLine("<" & myXPathNavigator.Name & ">")
' Show the attributes if there are any
If (myXPathNavigator.HasAttributes) Then
If (myXPathNavigator.MoveToFirstAttribute()) Then
strtemp = myXPathNavigator.Value
writer.Write(strtemp + Chr(9))
While (myXPathNavigator.MoveToNextAttribute())
'strtemp = fnRemoveKeyChars(myXPathNavigator.Value)
strtemp = myXPathNavigator.Value
writer.Write(strtemp + Chr(9))
End While
' Return to the 'Parent' node of the attributes
myXPathNavigator.MoveToParent()
End If
End If
End If
End Sub
Here writer is the streamwriter.
Any help is greatly appreciated.
Thanks
sp