0

I'd like to create an index and later, access some specific parts of a huge xml file, so I need to get the offset ( ftell ... ) for some 'startElement' Events.

Using the pull parser (stax) interface of libxml2 ( http://www.xmlsoft.org/xmlreader.html ) is it possible to get the offset in the stream of an event using libxml2 ?

Pierre
  • 34,472
  • 31
  • 113
  • 192

1 Answers1

1

Use the function xmlTextReaderByteConsumed:

long xmlTextReaderByteConsumed (xmlTextReaderPtr reader)

This function provides the current index of the parser used by the reader, relative to the start of the current entity. This function actually just wraps a call to xmlBytesConsumed() for the parser context associated with the reader. See xmlBytesConsumed() for more information.

reader: an XML reader
Returns: the index in bytes from the beginning of the entity or -1 in case the index could not be computed.

Community
  • 1
  • 1
nwellnhof
  • 32,319
  • 7
  • 89
  • 113