472,971 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Line number information in XmlDocument?

Is there a way to get line number information from an XmlDocument object?
As
I work with the various elements in the XmlDocument, I want to be able to
refer to the line number.

I found an article on extending the DOM, which seems to be exactly what I
want,
here:

http://msdn2.microsoft.com/library/e...us,vs.80).aspx

However, while it extends XmlElement to contain the line number information,
I can't
see where it is actually setting the line number information -- SetLineInfo
doesn't seem
to be called anywhere.

I know the XmlTextReader and other classes *do* contain line number
information, but
I don't want to use those for a variety of other reasons.

Can anyone help?

-- Greg Allen
Nov 12 '05 #1
1 9983
No it does not keep that information. But the XPathDocument does.

XPathDocument doc = new XPathDocument("..\\..\\dataset1.xsd");
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator iter = nav.Select("*");
if (iter.MoveNext()){
XPathNavigator root = iter.Current;
IXmlLineInfo info = root as IXmlLineInfo;
Console.WriteLine(info.LineNumber +"," + info.LinePosition);
}


"Greg Allen" <ga****@arrayinc.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
Is there a way to get line number information from an XmlDocument object?
As
I work with the various elements in the XmlDocument, I want to be able to
refer to the line number.

I found an article on extending the DOM, which seems to be exactly what I
want,
here:

http://msdn2.microsoft.com/library/e...us,vs.80).aspx

However, while it extends XmlElement to contain the line number
information, I can't
see where it is actually setting the line number information --
SetLineInfo doesn't seem
to be called anywhere.

I know the XmlTextReader and other classes *do* contain line number
information, but
I don't want to use those for a variety of other reasons.

Can anyone help?

-- Greg Allen

Nov 12 '05 #2

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

Similar topics

6
by: Milo Woodward | last post by:
Does anyone know how to retrieve the number of records an XML file contains with a vb.net method? I can read through an entire XML file, import records into SQL Server, etc. However, I don't want...
4
by: Arthur Hoornweg | last post by:
Hello World, any idea how I can convince MSXML.IXMLDOMDocument to save the XML files using CR/LF? I need to manually edit the XML files and it's awkward if everything is in one huge line.
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
3
by: Atara | last post by:
I use the following code to load xml file: Dim srcXml As String = pathDataFiles & "test.xml" Dim XmlDoc As New Xml.XmlDocument XmlDoc.Load(srcXml) If my xml file starts with the line - ...
12
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
11
by: kaisersose1995 | last post by:
Hi, I've got an import procedure working, using a standard import specification to import a .csv file into a temporary table. The problem i'm having is that i have 4 different sets of borrower...
2
by: mortb | last post by:
Why is line number and position = 0 in the code below? Valiation errors are found but not their position. cheers, mortb public static void Main() { XmlDocument xml = new XmlDocument();...
7
by: MaxMax | last post by:
I want to insert a white line between XML elements to raise human readability example: <MyNode> </MyNode> <MyNode> </MyNode>
14
by: anju458 | last post by:
Hi, I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.