473,698 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 myXPathNavigato r As XPathNavigator)
Dim strtemp As String = String.Empty
If Not (myXPathNavigat or.HasChildren) Then

If (myXPathNavigat or.NodeType = XPathNodeType.T ext) Then

' Console.Write(m yXPathNavigator .Value + Chr(9))
strtemp = myXPathNavigato r.Value
writer.Write(st rtemp + Chr(9))
ElseIf (myXPathNavigat or.Name <> String.Empty) Then
' Console.WriteLi ne("<" & myXPathNavigato r.Name & ">")
Else
'Console.WriteL ine()
End If

Else
'; Console.WriteLi ne("<" & myXPathNavigato r.Name & ">")

' Show the attributes if there are any
If (myXPathNavigat or.HasAttribute s) Then
If (myXPathNavigat or.MoveToFirstA ttribute()) Then
strtemp = myXPathNavigato r.Value
writer.Write(st rtemp + Chr(9))

While (myXPathNavigat or.MoveToNextAt tribute())

'strtemp = fnRemoveKeyChar s(myXPathNaviga tor.Value)
strtemp = myXPathNavigato r.Value
writer.Write(st rtemp + Chr(9))

End While

' Return to the 'Parent' node of the attributes
myXPathNavigato r.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 3771
"sp" <sp@discussions .microsoft.com> wrote in message news:83******** *************** ***********@mic rosoft.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******** *************** ***********@mic rosoft.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
1299
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). Older rows aren't needed so we have a process that deletes rows more than 30 days old (using delete statements). When these rows are deleted, is the memory consumed by these automatically recovered? Or is there some process that must be performed...
1
9195
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 will work for 9i and even 10g ) No one had what I needed, so I wrote it myself. I Rule. This code isn't going for efficiency, and isn't trying to be dynamic. It doesn't create the table structure in Oracle, that's up to you. (I
4
2066
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 prints and mails our bills. The application basically creates a table then exports a comma delimited file of that table. The problem is that we keep getting one seemingly random record in the text file that is misaligned. The record in question is...
2
2040
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 always 8K to 9K. I dont get the rest of the data. I think the data size is too big to come in one go and hence it comes in 2-3 sub-packages but my call back function only gets called once hence I am getting truncated data. I am sending the...
12
2222
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 reccount FROM Equipmenttbl " sql01 = sql01 & "WHERE Equipmenttbl.GrantID = " & GrantID
0
14418
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 be greater than 255 characters. 2. I have an access database. I link (not import) to the contents of the excel spreadsheet. In the design view in access, Column A has the data type "memo".
6
8210
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 can get the data into Access (from Payroll) and write a query with all the fields (inserting fields with spaces, as needed), but I can't figure out how to get it to export to a .txt file - without the field name header row. I don't really ...
10
22713
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) outFile.write("teststring", 10); outFile.close(); If I leave out the ios::ate and ios::app modes my string is written to the start of the file as I'd expect but I want to write the data to
7
22131
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 do so far is: f = file("friends.txt", "w")
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.