RE: [xml] please help me
- From: "Ron Ohmer" <rohmer aisconsulting net>
- To: "'shen peng'" <shenpeng77 hotmail com>, <xml gnome org>
- Subject: RE: [xml] please help me
- Date: Tue, 10 Feb 2004 12:21:46 -0500
The problem is most likely whitespace...
You have one of two answers:
1. Remove all whitespace, it is treated as node type 3 (As opposed to 1).
2. Check to see if the node type is 3, if it is, disregard (It is
whitespace).
Ron
-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org] On Behalf Of shen
peng
Sent: Tuesday, February 10, 2004 12:05 PM
To: xml gnome org
Subject: [xml] please help me
Hello,
I met one problem in reading string type of data from xml files.The problem
is like this:
I need to read the data from xml files,
<timetable>
<train number = "su1">
<train_type> x2000 </train_type>
<train_route>direct_train</train_route>
<departure_station>stockholm</departure_station>
<departure_hour> 5</departure_hour>
....
</train>
<train number = "sub2">
...
</train>
<train number = "sub3">
...
</train>
</timetable>
Using<libxml/parser.h>,there is one problem that really confuses me.
I use one structure to save the data read from xml. The data type of 'int'
'double' can save correctly. For instance,
<departure_hour> 5</departure_hour> can be correctly saved into the
structure.
but the type of string always have some mistake.I can only read successfully
the first strings data(<train number = "su1">),after that
all the strings data were wrong ,even when I check
if ((!xmlStrcmp(cur->name, (const xmlChar *)"train_route"))) {
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
route1_list.back().train_route=(char*)key;//using deque
printf("%s!!!!!\n",route1_list.back().train_route);//this is right
when
reading
printf("%s: %s\n",cur->name, key);//this is right
xmlFree(key);
}
the reading was correct, but the finally when I print all the member of
structure ,the string type of data is mess. I have check my program many
times, and could not solve it. Would you do me a favour to help me?
thanks
peng
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail
_______________________________________________
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]