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



That's true...

Actually if you were to do what I stated, you should check the type..


-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org] On Behalf Of Igor
Zlatkovic
Sent: Wednesday, February 11, 2004 5:21 PM
To: xml gnome org
Subject: [xml] Re: how to read the second node?

shen peng wrote:

Hello again ,thank you very much ,I solved last problem but the new 
question is coming out :(
the format of xml is like this :
<timetable>
    <direct_train>
        <train number = "suX1">
            .........
        </train>
        <train number = "suX2">
            .........
        </train>
    </direct_train>
    <passing1_train>
        <train1 number = "subX1">
            .........
        </train1>
    </passing1_train>
</timetable>
I can use followed code: doc = xmlParseFile(docname);
          cur = xmlDocGetRootElement(doc);
                      cur = cur->xmlChildrenNode;
         cur = cur->next;//this point to <direct_train>;

No way. If the document is what you have shown, that points to a text 
node that contains whitespace. That node is between <direct_train> and 
<train> and it contains a newline, carriage return perhaps, a few spaces 
and/or perhaps tabs.

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 ?

Use XPath to select the nodes you need. Walking the tree is never a good 
idea, unless you analyse an unknown XML structure.

Ciao,
Igor

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml




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