473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Data from xml file gets truncated when writing to text file

sp
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

Nov 12 '05 #1
2 3742
"sp" <sp@discussions.microsoft.com> wrote in message news:83**********************************@microsof t.com...
to my problem When I am writing data to the text file value of the last
record is getting truncated.


Where have you called Flush (and Close) on the StreamWriter, writer?

I don't see from the Sub you've furnished where / how you've opened
the StreamWriter, so perhaps you are calling Close outside of the Sub,
but if you're missing this call it's a likely cause for the stream to appear
incomplete.
Derek Harmon
Nov 12 '05 #2
sp
Mr. Harmon,

Thank you very much for taking time to look at my problem. Actually I
forgot to put those two statments in my program. Now, after using those
statements in my program its working fine.

Thankyou very much

regards
SP
"Derek Harmon" wrote:
"sp" <sp@discussions.microsoft.com> wrote in message news:83**********************************@microsof t.com...
to my problem When I am writing data to the text file value of the last
record is getting truncated.


Where have you called Flush (and Close) on the StreamWriter, writer?

I don't see from the Sub you've furnished where / how you've opened
the StreamWriter, so perhaps you are calling Close outside of the Sub,
but if you're missing this call it's a likely cause for the stream to appear
incomplete.
Derek Harmon

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: john.livermore | last post by:
Quick question about deleting data from SQL Server. We have a table that gets quite a bit of activity with an attribute of type text (inserts that store new text entries of 50-200k apiece)....
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
4
by: Jay | last post by:
This is a strange one that I can't seem to find a fix for. We have a Billing DB application (Access 2000 format) where we upload billing info in a comma delimited text file to our printer who...
2
by: bil.shah | last post by:
Hi, I am listening to a port for data but I am not able to recieve whole data, I only get truncated data. Client sends me data that exceeds 40K and the data I recieve in my callback function is...
12
by: Jack | last post by:
Since, I have not got some desired advise, I am reposting this for some asnwer/valuable suggestion. Thanks. THE FOLLOWING IS A PART OF CODE FROM A ASP PAGE <% sql01 = "SELECT COUNT(*) AS...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
10
by: rory | last post by:
I can't seem to append a string to the end of a binary file. I'm using the following code: fstream outFile("test.exe", ios::in | ios::out | ios::binary | ios::ate | ios::app)...
7
by: elnoire | last post by:
Greetings! I've just started learning python, so this is probably one of those obvious questions newbies ask. Is there any way in python to check if a text file is blank? What I've tried to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.