Re: [xml] internal tree ?

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Sun Oct 15 2000 - 15:43:13 EDT


On Sun, Oct 15, 2000 at 07:05:43PM +0200, Michael Liehmann wrote:
>
> Hi !
>
> as this is my first message to this mailing list, i hope that
> my question or problem is not too dumb .
>
> well i try to write a XMLmodule for MetaHTML.
> at the moment i am still probing around and try to understand the
> internal presentation of the tree, the parser returns.
>
>
> i used this small xml example file from xmlsoft.org
> <?xml version="1.0"?>
> <EXAMPLE prop1="gnome is great" prop2="&amp; linux too">
> <head>ddd
> <title>Welcome to Gnome
> <sub>suse</sub>
> </title>
> </head>
> <chapter>eins
> <title>The Linux adventure</title>
> <p>bla bla bla ...</p>
> <p>...</p>
> </chapter>
> </EXAMPLE>
>
>
> here comes the testfile
> ...
> ...
>
> doc = xmlParseFile("xmlFile2.xml");
> if (doc == NULL) return(NULL);
> cur = xmlDocGetRootElement(doc);
>
> now, cur is the root tag ( = <EXAMPLE> )
> and with printf("%s\n",cur->name) i get the right tagname
>
> with printf("%s\n",cur->xmlChildrenNode->next->name) i get the name of
> the <head> tag

  Make sure you use libxml2

  you should have
    cur->children pointing to a text node
    cur->children->next pointing to head
    cur->children->next->next to a text node
    cur->children->next->next->next to chapter

 use xmllint --debug xmlFile2.xml

   to get a complete view of the built tree

> ok, but then the questions start!
> how can i reference the <chapter> tag?
> or the second title tag ( = the linux adventure)
> how can i parse throug the whole tree!

  next <-> prev
  children <-> parent
  and attributes <-> parent to access the list of attributes

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Oct 15 2000 - 15:43:22 EDT