You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Ron Rothblum <RO...@il.ibm.com> on 2002/12/15 10:13:08 UTC

DOM Location

Hi,
I am not sure if this is the right place to be asking this question but I
was wondering if anyone knows of a way to find the location in the XML file
of a DOM parsed node.

thanks,
Ron.



---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: DOM Location

Posted by Andy Clark <an...@apache.org>.
Paul Libbrecht wrote:
> It should be worthwile to be said that SAX supports 
 > this out of the box...

I don't think this is a question of reporting line
numbers but, rather, in retaining that information
and associating it to the relevant DOM nodes (since
the question was regarding DOM). Since SAX does not
retain any information about the document, the app
would still need to store that information.

-- 
Andy Clark * andyc@apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: DOM Location

Posted by Paul Libbrecht <pa...@activemath.org>.
Ron Rothblum wrote:
> I am not sure if this is the right place to be asking this question 
> but I
> was wondering if anyone knows of a way to find the location in the XML 
> file of a DOM parsed node.

It should be worthwile to be said that SAX supports this out of the 
box...

Paul


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: DOM Location

Posted by Andy Clark <an...@apache.org>.
Ron Rothblum wrote:
> I am not sure if this is the right place to be asking this question but I
> was wondering if anyone knows of a way to find the location in the XML file
> of a DOM parsed node.

You could extend the DOMParser class in order to
keep track of line/column numbers on the callbacks.
Then, you can add this information to the DOM node
that is created. The DOM Level 3 specification has
added methods for handling associated user data.
But please note that DOM Level 3 is not yet
finalized.

There is a sample, dom/DOMAddLines.java, included
with the Xerces package that shows this functionality.

-- 
Andy Clark * andyc@apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: DOM Location

Posted by Jeff Turner <je...@apache.org>.
On Sun, Dec 15, 2002 at 11:13:08AM +0200, Ron Rothblum wrote:
> Hi,
> I am not sure if this is the right place to be asking this question but I
> was wondering if anyone knows of a way to find the location in the XML file
> of a DOM parsed node.

I'd try Document.getElementsByTagName() or http://jaxen.org/

--Jeff

> thanks,
> Ron.
> 

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org