Each XML node created by libxml2 has: if it is an element (as determined by xmlIsElement), an optional element name, which is a string and is obtained with xmlGetName; if it is text (as determined by xmlIsText), an optional content string, obtained with xmlGetContent; a linked list of attributes of type LibxmlAttribute; a linked list of children (which are XML nodes), obtained with xmlFirstChild; and a pointer its next sibling, obtained with xmlGetNext.
XML nodes are mutable.
Internally, a pointer to the XML document containing the node accompanies the node.
Let's use xmlParse to make an XML node.
|
|
Since it is an element, we may use xmlGetName to get its name.
|
We use xmlFirstChild to get the first node in the linked list of children, which happens to be text:
|
|
We may follow the linked list of children of n.
|
|
|
|
|
|
Let's examine the attributes of bar.
|
|
|
We may disassemble an attribute as follows.
|
|
|
|
|
There are other functions that retrieve the entire list of attributes or children.
|
|
|
|
The object LibxmlNode is a type, with ancestor class Thing.