Re: [xml] How to access byte-offset of XML node with Gnome C Parser of libxml2 ?
- From: Daniel Veillard <veillard redhat com>
- To: Sukomal Pal <sukomalpal gmail com>
- Cc: xml gnome org, mandar isical ac in
- Subject: Re: [xml] How to access byte-offset of XML node with Gnome C Parser of libxml2 ?
- Date: Wed, 19 Jul 2006 09:35:28 -0400
On Tue, Jul 18, 2006 at 11:34:23PM +0530, Sukomal Pal wrote:
Hi,
it would be nice if people stopped posting stuff twice to the list !
Could anyone please suggest us how we can keep track of byte-offset
value of a XML-node during parsing of a XML file with Gnome C parser ?
In general it's a wrong idea because it mixes two unrelated logical
model. Tell me what the byte offset should be when you hit
- a caracter coming from a predefined entity
- a character coming from an entity defined in the internal subset
- a character coming from an entity defined in the external subset
if you really are ready to see your sequence do something like
1000 1001 20 21 22 23 24 25 26 27 1008 1009
and okay to cope with it then sure byte offset may make sense !
Presently the structure 'xmlParserNodeInfo' gives the begin-line
number and end-line number. But I need to know the byte-offset value
of the node w.r.t. to the start of the file. Please help.
In general it's a very wrong thing to do.
You can still try to look at xmlByteConsumed and xmlTextReaderByteConsumed
functions from the API, but again, unless you really know what you are doing
it's a very wrong thing to ask an XML parser. An index in a file is a well
defined concept. Once you started parsing the model is completely different.
I would say, forget about it, again unless you really really understand
all trhe tricks a parser may play on you.
Daniel
--
Daniel Veillard | Red Hat http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]