Re: [xml] xmlReader: Possibility for cloning an xmlTextReader (or multi-pass reading)

On Sat, Mar 30, 2013 at 08:57:55PM +0100, Martin B. wrote:
On 30.03.2013 16:35, Daniel Veillard wrote:
On Sat, Mar 30, 2013 at 08:02:38AM +0100, Martin B. wrote:
But as far as I can grasp this, an xmlTestReader is just an
"object", encapsulating access to an XML document, and in the case
of a local file it a set of attributes that made up the parser state
and a byte offset into the file. Copying such an "object" should be
pretty trivial in priciple, or shouldn't it? (You write above:
"can't always clone an I/O path" -- for reading from a named file,
it should be trivial though, shouldn't it?)

  no, the file can be converted to a different encoding on the fly,
and the parser can't work directly from a file index, it is
unfortunately far more complex than that.

If I can't re-read part of a file, I could also re-read the whole
file, ...

Is there maybe a simple way to remember for a xmlTextReader where it
is in the current document, ...

Hum, no, ...
You will iterate on the Read() though, assuming you don't do other
progress operations, just count them, and then when going through the
second time run a loop with the same number of Read() you should be
at the same place if the input didn't changed !

Just counting the reads sound like an excellent idea! Thanks!

  That should Just Work, is rather trivial to implement assuming the
file doesn't change and you can keep easilly many 'places' in that
document, since its just a counter.


Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit | virtualization library

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]