Is it possible to track the file pointer (document position) using the XML API?

I want to index an XML file by the ids of its main level records. I am planning to parse the entire document, extract the id from the post and index it (remember the file position of the opening tag <

and the position of the closing tag >

+ 1). Later, this will allow me to quickly find this place by ID.

But is it possible to track the position of a file using SAX?

If this is not possible with SAX, then is there some other parser for it?

UPDATE

I found that Location has a method getCharacterOffset()

. Is this the meaning StAX

?

UPDATE 2

Location

works, but somehow unexpectedly. The first tag mediawiki

and starts at zero. getCharacterOffset()

Returns 4 at the same time from the start of processing.

It looks like what is in front in front.

+3
java xml sax stax file-pointer


source to share


No one has answered this question yet

Check out similar questions:

797
What characters do I need to hide in XML documents?
492
How do I parse XML files?
442
How to deserialize an XML document
2
Serializing DOM DOM Document to XML: Adding CData Elements
2
Which XML parser meets these requirements?
2
How StAX Handles XML Changes
1
Stax vs Sax vs DOM parser?
0
Sax Stax Fragment Processing in Java
0
Parsing multiple XML files
0
Python SAX parser says XML file is not valid



All Articles
Loading...
X
Show
Funny
Dev
Pics