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

XmlTextReader, LineNumber, and total number of lines?

Can I determine how many lines an xml file has so I can say something
like "line 4 of 254"?

Nov 12 '05 #1
3 3481
SirPoonga wrote:
Can I determine how many lines an xml file has so I can say something
like "line 4 of 254"?


Use IXmlLineInfo interface, which XmlTextReader implements. See
http://msdn.microsoft.com/library/de...classtopic.asp

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #2
I have seen that and that is why I am asking the question. I can not
see a way of determining total number of lines prior to reading through
the entire file with XmlTextReader.
The information on XmlTextReader and IXmlLineInfo only shows depths,
line number, and line position. Unless there is a total lines I am
missing?
Am i going to first have to poen the file with StreamReader, read in
line by line to count number of lines first?

Nov 12 '05 #3
SirPoonga wrote:
I have seen that and that is why I am asking the question. I can not
see a way of determining total number of lines prior to reading through
the entire file with XmlTextReader.
Sure. That's by design. XmlTextReader is forward-only non caching XML
parser.
Am i going to first have to poen the file with StreamReader, read in
line by line to count number of lines first?


If you don't need line info for elements, of course you can just count
lines using non-XML reader.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #4

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

Similar topics

0
by: Paul L | last post by:
I'm using SAX to parse a valid XML document without a DTD. If the document has extra whitespace as blank lines, the lineNumber reported by the Locator is in correct, by a line or two. Is their some...
5
by: Jan Schneider | last post by:
Hi, I already tried all positioning combinations I could think of without succes. Here is what I try to achieve: If want to have a floating text (no divs allowed, only spans) where linenumber...
3
by: keldan | last post by:
I am hoping someone on this list can shed some light on the below issue for me. I am using XmlTextReader to read from an XML file. Unfortunately, an exception is thrown ("Index was outside the...
36
by: Wei Su | last post by:
Hi, I have a text file abc.txt and it looks like: 12 34 56 23 45 56 33 56 78 ... .. .. ... .. .. I want to get how many rows totally in the text file, how to do this? Thanks.
10
by: Craig Bumpstead | last post by:
Hi, I was wondering the best and fastest way to determine how many lines are in a log file. At the moment I am simply doing a StreamReader.ReadLine and incrementing a counter until I reach...
1
by: Eric M L | last post by:
I am wondering if I am alone with this problem. Using VS 2005, I must validate an XML file via a Schema and it works well. When I get the schema exception and check the LineNumber and...
13
by: Rick | last post by:
The following code will enter an infinate loop when in ReadChars. I can only make it happen when reading a Stream and with this particular XML. If I use the ReadInnerXml call rather than my own...
2
by: CindyH | last post by:
Hi I have a http xml post that I'm trying to read using xmltextreader. This is the xml: <?xml version="1.0"?> <userlist ACTION="newuser" VENDORNAME="H2Digital"> <amouser AMOAID="101"...
0
by: sena87 | last post by:
As the title says, can anyone tell me how to get the number of child nodes for lets say <script> node in the xml below using XmlTextReader? (which should be 2 - row1 and row2 ) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.