Re: [xml] Simple parsing XML question...



Nima ,

 

Remember also to free the returned string using xmlFree() as it is allocated on heap via xmlNodeListGetString()

 

xmlChar* pszNodeContent = NULL;

pszNodeContent = xmlNodeListGetString(m_ptrXMLDoc,ptrCurrXMLNode->children,1);

if (pszNodeContent)

{

            printf(“Value of <pic_file>  = %s”, (const char*)pszNodeContent);

            xmlFree(pszNodeContent);

            pszNodeContent = NULL;

}

 

-- Lav

 


From: Lav Mehrotra
Sent: Tuesday, June 10, 2008 11:56 AM
To: 'Nima Tiran'
Cc: xml gnome org
Subject: RE: [xml] Simple parsing XML question...

 

Nima ,

 

Plz use the following API()

 

xmlNodeListGetString(xmlDocPtr doc , xmlNodePtr list , int inline )

 

Get the (xmlDocPtr doc) from xmlParseFile(const char* filename) API or xmlParseMemory(const char* buffer , int size)

 

Get the Current (xmlNodePtr list) for ur node  <pic_file> by traversing the DOM Document Tree , until u encounter a node with  xmlNodePtr->name as same as pic_file  ( Take the help of xmlStrcmp() API ) . Say this node is xmlNodePtr pXmlNodePicFile

 

Once u have this pXmlNodePicFile u cannot blindly use pXmlNodePicFile->content as the TEXT Content MyPicFileName.pdf is also a child node of  the pXmlNodePicFile

 

So pass the 1st child of pXmlNodePicFile to xmlNodeListGetString() API like this

 

xmlNodeListGetString(doc, pXmlNodePicFile->children , 1)

 

Regds,

 

Lav

 


From: xml-bounces gnome org [mailto:xml-bounces gnome org] On Behalf Of Nima Tiran
Sent: Tuesday, June 10, 2008 3:11 AM
To: xml gnome org
Subject: [xml] Simple parsing XML question...

 

Hi  all,

 

I'm newbie here and got a simple question:

 

I'm parsing an XML file and having a node like:

 <pic_file>MyPicFileName.pdf</pic_file>   

 in  XML file, just wondering how can I retrieve "MyPicFileName" from this node?

 

Thnx

Nima

 

 

 

 

DISCLAIMER:
This email may contain confidential or privileged information for the intended recipient(s) and the views expressed in the same are not necessarily the views of Zensar Technologies Ltd. If you are not the intended recipient or have received this e-mail by error, its use is strictly prohibited, please delete the e-mail and notify the sender. Zensar Technologies Ltd. does not accept any liability for virus infected mails.



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