RE: [xml] how to read the second node?

Ok, here is how you would do it (Sorta, this is not code but an example)..

doc=xmlDocGetRootElement(docname); // TIMETABLE
cur=cur->xmlChildrenNode;               // direct_train

Ok, now our pointer is @ direct train, assume we want to got to the next
node @ this level..

We would call cur=cur->next.            // This would yield passing1_train

If we wanted to got to direct_train's child instead of passing1_train:

Or for a final example..  Lets say we were @ <train number> on <direct
train> and we wanted to go back to direct train:


Basically, look @ it like an outline where numbers below are levels of
depth, and letters are individual rows..

1       2       3       4

To go right in depth (i.e. A child) you would call xmlChildrenNode.
To go left in depth (i.e. A parent) you would call ->parent

To go down (Same level, next item) you would call ->next
To go up (Same level, previous item) you would call ->prev

I hope this clarifies this for you..

If you want to make this (A. Harder to write initially && B. Easier to use
in the future, use recursion).

Ron Ohmer

-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org] On Behalf Of shen
Sent: Wednesday, February 11, 2004 4:12 PM
To: xml gnome org
Subject: [xml] how to read the second node?

Hello again ,thank you very much ,I solved last problem but the new question

is coming out :(
the format of xml is like this :
                <train number = "suX1">
                <train number = "suX2">
                <train1 number = "subX1">
I can use followed code: doc = xmlParseFile(docname);
                  cur = xmlDocGetRootElement(doc);
                          cur = cur->xmlChildrenNode;
                 cur = cur->next;//this point to <direct_train>;
to read the <timetable> as root node ;<direct_train> as its childrennode,but

when I finish read the data in <direct_train>,I want to read data in 
<passing1_train>, do I need go back to the root node"<timetable>", and 
choose second
childrennode"<passing1_train>"? how can I do ?

thank you in advance

MSN 8 with e-mail virus protection service: 2 months FREE*

xml mailing list, project page
xml gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]