Connecting Tech Pros Worldwide Help | Site Map

Line number information in XmlDocument?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 03:48 AM
Greg Allen
Guest
 
Posts: n/a
Default 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



  #2  
Old November 12th, 2005, 03:48 AM
Chris Lovett
Guest
 
Posts: n/a
Default Re: Line number information in XmlDocument?

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" <gallen@arrayinc.com> wrote in message
news:eDAoionnFHA.2472@tk2msftngp13.phx.gbl...[color=blue]
> 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
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.