Re: byte offset

Michael Ludwig <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
subs subs schrieb:
>
> Iam parsing an  xml document using XML::SAX. I would like to know how
> to get the offset position of an element while parsing. Basically, I
> want to get the offset of every occurence of a particular element in
> my xml file.

Referring you to the answer Daniel Veillard gave to a similar question
on the LibXML2 list:

Gnome - Lib - Xml - General - Getting the offset of a node in the stream
http://www.nabble.com/Getting-the-offset-of-a-node-in-the-stream-td24864815.html

   "All you can get is at what point the parser is at that given time. If
   using SAX (which I don't suggest) then you get something relatively
   precise, but it can be extremely costly. For the reader it progresses
   by chunk and what you get is the end of the latest parsed chunk (hence
   ahread of the current node).

   In general looking for the offset is just the wrong way to proceed,
   XML is structured data, and the best addressing parttern is tu use the
   structure (XPath/XPointer), anything else will give poor or costly/
   unprecise results."

Like Daniel, I'd recommend XML::Reader over XML::SAX. It's easier.

-- 
Michael Ludwig
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.