473,378 Members | 1,078 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,378 software developers and data experts.

ReadOuterXml Issue

When I try to do the following in a vb.net application:


Expand|Select|Wrap|Line Numbers
  1. While xtr.Read() And recordCnt < loopCount
  2.  
  3. If xtr.NodeType = XmlNodeType.Element Then
  4. If (xtr.Name = "Employee") Then
  5. recordCnt = recordCnt + 1
  6. strWriter = New StringWriter
  7. UID = ""
  8. strWriter.Write(xtr.ReadOuterXml)
  9. Dim xdoc As New XmlDocument
  10. 'writeObj = CreateObject("MSXML2.DOMDocument")
  11.  
  12.  
  13. If docType = "devplan" Then
  14. xdoc.LoadXml("<?xml version=""1.0"" encoding=""utf-16"" ?><Batch><DevelopmentPlan>" & strWriter.ToString & "</DevelopmentPlan></Batch>")
  15. Else
  16. xdoc.LoadXml("<?xml version=""1.0"" encoding=""utf-16"" ?><Batch><TalentProfile>" & strWriter.ToString & "</TalentProfile></Batch>")
  17. End If
  18. End While
  19.  
  20.  
Every other record seems to get skipped when I try to use readouterxml within the while read() loop. Any ideas why this happening or what I can do to fix this issue?

Thanks.
May 17 '07 #1
3 1780
TRScheel
638 Expert 512MB
When I try to do the following in a vb.net application:


Expand|Select|Wrap|Line Numbers
  1. While xtr.Read() And recordCnt < loopCount
  2.  
  3. If xtr.NodeType = XmlNodeType.Element Then
  4. If (xtr.Name = "Employee") Then
  5. recordCnt = recordCnt + 1
  6. strWriter = New StringWriter
  7. UID = ""
  8. strWriter.Write(xtr.ReadOuterXml)
  9. Dim xdoc As New XmlDocument
  10. 'writeObj = CreateObject("MSXML2.DOMDocument")
  11.  
  12.  
  13. If docType = "devplan" Then
  14. xdoc.LoadXml("<?xml version=""1.0"" encoding=""utf-16"" ?><Batch><DevelopmentPlan>" & strWriter.ToString & "</DevelopmentPlan></Batch>")
  15. Else
  16. xdoc.LoadXml("<?xml version=""1.0"" encoding=""utf-16"" ?><Batch><TalentProfile>" & strWriter.ToString & "</TalentProfile></Batch>")
  17. End If
  18. End While
  19.  
  20.  
Every other record seems to get skipped when I try to use readouterxml within the while read() loop. Any ideas why this happening or what I can do to fix this issue?

Thanks.

Should be a xtr.OuterXML

ReadOuterXML will advance it if I remember correctly
May 17 '07 #2
I am using XmlTextReader and Outer XML is not property within this class.
May 17 '07 #3
TRScheel
638 Expert 512MB
I am using XmlTextReader and Outer XML is not property within this class.
I would advise avoiding xmltextreader... At least, I really dont like it. Props to you use it. I prefer doing something like this:
Expand|Select|Wrap|Line Numbers
  1.         Dim SReader As System.IO.StreamReader = New System.IO.StreamReader(filelocation)
  2.         Dim XMLDocument As System.Xml.XmlDocument
  3.         XMLDocument.LoadXml(SReader.ReadToEnd())
  4.         SReader.Close()
  5.  
  6.         'Use XMLDocument from here on out...
May 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
0
by: Skunker | last post by:
hi, when I read a file, ReadOuterXml() returns sometimes an empty string and somestimes not. does anyone have a clue? here´s a part of the code, i hope i helps: // used to parse wordML Tables...
3
by: wijay2k | last post by:
i'm converting a C# program which parses a XML file into java. in c# the ReadOuterXml() method is used to pullout the whole content of a particular element tag. i need a similar kind of method or...
1
by: stvnegert | last post by:
When I try to do the following in a vb.net application: While xtr.Read() And recordCnt < loopCount If xtr.NodeType = XmlNodeType.Element Then If (xtr.Name =...
1
by: dignan.tenenbaum | last post by:
Hello, I'm using the XmlReader.ReadOuterXml() method to return the string representation of an xml node. The XmlReader is created with a file path and a XmlReaderSettings object. This was...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.