[xml] xmlFirstElementChild() & xmlChildElementCount() was not decalared in this scope



Hi

I have a simple xml file which I am trying to parse but I am having some problem under debian-lenny with g++ using the functions    

*    xmlFirstElementChild()
*    xmlChildElementCount()

Error Reported by g++:

‘xmlChildElementCount’ was not declared in this scope
‘xmlFirstElementChild’ was not declared in this scope

The above functions work fine under Windows-XP when using the MSVC compiler under VS-2005...

libxml2 version on debian is 2.6.32.dfsg-5+lenny1

The XML file and the function looks like ....

<CAST>
  <GRAMMAR _id="1">
    <LEVEL id="0" minoccurance="1" maxoccurance="1">
      <GROUP id="0">
        <MODEL id="27" text="STARTSIL" />
        <CONNECTINFO level="-1" group="-1" />
      </GROUP>
    </LEVEL>
    <LEVEL id="1" minoccurance="1" maxoccurance="1">
      <GROUP id="0">
        <MODEL id="0" text="DRINK" />
        <MODEL id="1" text="TV" />
        <MODEL id="2" text="RADIO" />
        <MODEL id="17" text="HELLO" />
        <MODEL id="18" text="DOOR" />
        <MODEL id="19" text="WINDOW" />
        <CONNECTINFO level="0" group="0" />
      </GROUP>
    </LEVEL>
    <LEVEL id="2" minoccurance="1" maxoccurance="1">
      <GROUP id="0">
        <MODEL id="28" text="ENDSIL" />
        <CONNECTINFO level="1" group="0" />
      </GROUP>
    </LEVEL>
  </GRAMMAR>
  <GRAMMAR _id="2">
    <LEVEL id="0" minoccurance="1" maxoccurance="1">
      <GROUP id="0">
        <MODEL id="27" text="STARTSIL" />
        <CONNECTINFO level="-1" group="-1" />
      </GROUP>
    </LEVEL>
    <LEVEL id="1" minoccurance="1" maxoccurance="1">
      <GROUP id="0">
        <MODEL id="3" text="CUP" />
        <MODEL id="4" text="GLASS" />
        <MODEL id="5" text="PINT" />
        <MODEL id="16" text="DELETE" />
        <CONNECTINFO level="0" group="0" />
      </GROUP>
    </LEVEL>
  </GRAMMAR>
</CAST>


int main(int argc, char* argv[])
{
 
    xmlDocPtr doc;
    xmlNodePtr docCur,gramCur,inCur;
    unsigned long levelCount;
     
    doc = xmlParseFile((const char *) "v2.xml");     
 
    if(doc == NULL)
        return 1;
     
     
    docCur = doc->children; //At <CAST>
     
    if (docCur == NULL) {
        xmlFreeDoc(doc);
        return 1;
    }
 
    if (xmlStrcmp(docCur->name, (const xmlChar *) "CAST")){
        xmlFreeDoc(doc);
        return 1;
    }
 
 
    gramCur=docCur->children; // At First Grammar Now
    //gramCur=xmlFirstElementChild(docCur);
   
    //levelCount=xmlChildElementCount(gramCur);//number of levels
    //cout<<"number of levels are: "<<levelCount<<endl<<endl;
 
    while(gramCur != NULL){
 
        if(gramCur->type != XML_TEXT_NODE){
            printf("%s\n",gramCur->name);
             
            for(inCur=gramCur->children;inCur!=NULL;inCur=inCur->next){
                if(inCur->type != XML_TEXT_NODE)
                    printf("      %s: \n",inCur->name);
            }
        }
        gramCur=gramCur->next;
    }
 
    return 0;
}


When I try uncommenting the above three lines I get the error that the "functions were not declared in the scope"

Am I missing some important header file for these functions under linux or need to install some extra library.

Any help will be great...

Thanks
Sid


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