# The XML C parser and toolkit of Gnome ## The tree output

Developer Menu
Main Menu Reference Manual Code Examples XML Guidelines Tutorial The Reader Interface ChangeLog XSLT Python and bindings libxml2 architecture The tree output The SAX interface Memory Management I/O Interfaces The parser interfaces Entities or no entities Namespaces Upgrading 1.x code Thread safety DOM Principles A real example flat page, stylesheet
API Indexes
Alphabetic Constructors Functions/Types Modules Symbols
Related links
Mail archive XSLT libxslt DOM gdome2 XML-DSig xmlsec FTP Windows binaries Solaris binaries MacOsX binaries C++ bindings PHP bindings Pascal bindings Ruby bindings Tcl bindings Bug Tracker
The parser returns a tree built during the document analysis. Thevaluereturned is an xmlDocPtr(i.e., a pointer toanxmlDocstructure). This structure contains informationsuchas the file name, the document type, and achildrenpointerwhich is the root of the document (or moreexactly the first child under theroot which is the document). The tree ismade of xmlNodes,chained in double-linked lists of siblingsand with a children<->parentrelationship. An xmlNode can also carryproperties (a chain of xmlAttrstructures). An attribute may have a valuewhich is a list of TEXT orENTITY_REF nodes. Here is an example (erroneous with respect to the XML spec sincethereshould be only one ELEMENT under the root): In the source package there is a small program (not installed bydefault)called xmllintwhich parses XML files given asargument andprints them back as parsed. This is useful for detecting errorsboth in XMLcode and in the XML parser itself. It has an option--debugwhich prints the actual in-memory structure of thedocument; here is theresult with the examplegivenbefore:
    DOCUMENT
    version=1.0
    standalone=true
      ELEMENT EXAMPLE
        ATTRIBUTE prop1
          TEXT
          content=gnome is great
        ATTRIBUTE prop2
          ENTITY_REF
          TEXT
          content= linux too
        ELEMENT head
          ELEMENT title
            TEXT
            content=Welcome to Gnome
        ELEMENT chapter
          ELEMENT title
            TEXT
            content=The Linux adventure
          ELEMENT p
            TEXT
            content=bla bla bla ...
          ELEMENT image
            ATTRIBUTE href
              TEXT
              content=linus.gif
          ELEMENT p
            TEXT
            content=...
This should be useful for learning the internal representation model. Daniel Veillard