[xml] Missing usage pattern from .NET XmlReader in libxml2 XmlTextReader?


I read[1] that XmlTextReader interface is based on .NET XmlReader
class. I like XmlTextReader but can't find a way to perform a pattern
I often use in .NET: create a XmlReader of a subtree at any point of
the document. In .NET I do this to perform manual XML deserialization:

    while (reader.Read())
        switch (reader.Name)
            case XML_ELEM_NAME:
                _Name = reader.ReadString();
            case XML_ELEM_SIZE:
                _Size = new Vector3D();
                _Size.Deserialize(reader.ReadSubtree());  // <--------
    // ...

To explain, when I find the element "SIZE", I create a new XmlReader
with the entire subtree so I can continue parsing the subtree in a
different function using the *same* api. With libxml2 XmlTextReader I
couln't find a way to do the same: I found xmlTextReaderExpand() that
return a node to the current subtree but is it possible to use
XmlTextReader api given a xmlNodePtr? To summarize: I'd like to use
XmlTextReader api in a subtree (and just in that subtree) but don't
know how to do it.


[1] http://xmlsoft.org/xmlreader.html

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