[xml] Child Traversing loop runs twice
- From: siddharth sehgal <mailsid gmail com>
- To: xml gnome org
- Subject: [xml] Child Traversing loop runs twice
- Date: Tue, 16 Feb 2010 11:44:16 +0000
Hi
I am new to libxml2 and intend to use it in my application which will run on embedded windows/ linux. I was trying to get hold of some common xml parsing routines and there is an interesting observation which I cannot resolve. although the xml I am parsing is a bit more elaborative but the observation persists on simple xml like this also.
<?xml version="1.0" ?>
<CAST>
<a />
<b />
<c />
</CAST>
xmlDocPtr doc;
xmlNodePtr topcur;
.
.
doc = xmlParseFile(ansiSTR);
.
.
topcur = doc->children;//xmlDocGetRootElement(doc);//At <CAST>
.
.
topcur=topcur->children;
while(topcur != NULL){
printf("%s\n",topcur->name);
topcur=topcur->next;
}
Output expected is:
a
b
c
Actual Output:
text
a
text
b
text
c
text
The loop for child traversing runs twice. I cant figure this out . Any suggestions will be deeply appreciated.
thanks
Sid
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]