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.