docs/examples on libxml2 type system?

Posted by Wang on Stack Overflow See other posts from Stack Overflow or by Wang
Published on 2010-02-07T23:13:11Z Indexed on 2010/03/30 6:13 UTC
Read the original article Hit count: 583

Filed under:
|
|

I'm reading through the libxml2 API and examples on xmlsoft.com and having some real difficulty wrapping my head around the type system. For example, the _xmlAttribute struct has an xmlChar* field called name. This obviously refers to the name of the attribute (e.g., "bar" for the struct tied to the element <foo bar='baz' />). The _xmlAttribute struct also has a field called value, which I would expect to be "baz", except the type is xmlNodePtr. Um, what?

I guess I could write up some test code and examine the memory in gdb, but there has to be an easier way. Has anyone written up examples of the data structures generated by a libxml2 parser? I'm looking for an English prose text, not generated documentation, that will walk me through the various types and the values they take when parsing some example bit of XML.

Bonus points if it presents only the subset of libxml2 needed to read and write a config file---no namespaces or XPath or even modifying an existing document, just parse some XML, access the data, and then write it out again.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about libxml2