473,748 Members | 9,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3520
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
1272
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 property or something to set to get these numbers to come out correct? Paul
5
2090
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 appear in front of the text lines (being indented a certain space). It should look like:
3
4224
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 bounds of the array.") when the reader reaches the DOCTYPE. If I remove it everything works fine. Should I be handling the DOCTYPE someway before I read the DOCTYPE? Any insight would be greatly appreciated. I have provided a sample XML...
36
3656
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
7621
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 the end. Is there a better way?? Cheers, Craig
1
2868
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 LinePosition properties, they are always set to 0 <=== Here are 2 ways I used to validate the XML always getting LineNumber and LinePosition = 0. Any hints would be greatly appreciated. ==================================================================
13
3276
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 ReadElementBodyAsXml the code works, but is less efficent. ReadElementBodyAsXml is required by my application with .Net Framework 1.1. The code breaks on the second call to ReadElementBodyAsXml with the inner xml: </EGDConfigExtension>...
2
1418
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" AMOUSERNAME="Billy hill" AMOAROLES="Student" AMOAPRODUCTS="intralase,VISX,ILASKI" /> </userlist>
0
1023
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 ) ---------Test.xml----------- <?xml version="1.0" encoding="utf-8" ?> <Script> <row1> <dlgue>this is the tool i made</dlgue> <ava>angeline</ava> <exp>happy</exp> <pos>left</pos>
0
8984
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
8823
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
9312
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
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
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.