[xml] help required in libxml parser



Hi,
   I'am currently trying to develop a small prototype where i tried using libxml parser. and i'am now facing 
a couple of problems while parsing. I think my understanding is not clear in those. 

i'am basically trying to read a xml configuration file , parse it and then use that data in my code.

my xml doc looks something like this (docname2)( i formatted it now):

  <?xml version="1.0" ?> 
- <xmlbhas>
-    <protocolname>WAP1.2 
-       <layer>WSP 
-         <parameter>Version 
            <required>M</required> 
            <size>2</size> 
          </parameter>
-         <parameter>CapabilitiesLen 
            <required>M</required> 
            <size>2</size> 
          </parameter>
-         <parameter>Capabilities 
            <required>C</required> 
            <size>C</size> 
-           <condition>
               <name>CapabilitiesLen</name> 
               <condvalue>size</condvalue> 
            </condition>
          </parameter>
        </layer>
     </protocolname>
  </xmlbhas>


in my code i use something like this (some imp lines of the sample code):

xmlDocPtr doc2 = NULL;
xmlNodePtr cur1 = NULL;
xmlNodePtr tempnode1 = NULL;
xmlNodePtr tempnode2 = NULL;
xmlChar * nodevalue1;
xmlChar * nodevalue2;

doc2 = xmlParseFile(docname2);
cur2 = xmlDocGetRootElement(doc2);

cur2 = cur2->xmlChildrenNode->xmlChildrenNode;

tempnode1 = cur2->xmlChildrenNode;
nodevalue1 = xmlNodeListGetString(doc2, tempnode1->xmlChildrenNode, 1);
tempnode2 = tempnode1->xmlChildrenNode;
nodevalue2 = xmlNodeListGetString(doc2, tempnode2->xmlChildrenNode, 1);
and when i print the value of nodevalue2, i thought that i would get the value "M"   (the text in the 
"required" element) but i get a segmentation fault. I think tempnode2 became a null ptr. 
can anyone explain this is to me. I followed the example in the example dir in the libxml.

Also being new to unix and especially makefiles, i just changed the existing makefile in the example dir for 
my program and teh ourput i get is a shell script. But i would prefer it to be an executable binary. what all 
do i need to change for this? it would be really great if someone can show that from teh makefile of example 
dir.

Thanks and BR
Bhaskar Maddala

Attachment: InterScan_Disclaimer.txt
Description: Text document



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