LibXML2 + 拉解析器 (stax):事件的流位置 (ftell)?

LibXML2 + pull parser (stax) : stream position (ftell) of the event ?

我想创建一个索引,然后访问一个巨大的 xml 文件的某些特定部分,所以我需要获取 offset ( ftell ... ) 对于某些 'startElement' 事件。

使用libxml2(http://www.xmlsoft.org/xmlreader.html)的pull parser(stax)接口是吗可以使用 libxml2 ?

获取事件流中的偏移量

使用函数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.