Posted on 2008-11-21 11:55:56-08 by kumar1
how to get a sub node and their contents
Hi Is there any api to get the subnodes and contents of it directly using Libxml for example like below
<LinkType> <DeviceNbr>vijay</DeviceNbr> <ChipRevision>1</ChipRevision> <ChipName>PNP531</ChipName> <FirmwareVersion>2.1</FirmwareVersion> <FirmwareRevision>2.0</FirmwareRevision> <UserTimeout>10</UserTimeout> </LinkType />
I need the firmwareVersion Content. Thanks in Advance -Regards Kumar
Direct Responses: 9397 | Write a response
Posted on 2008-11-21 20:11:59-08 by eserte in response to 9390
Re: how to get a sub node and their contents
Easiest is too use XPath expressions. Untested:
$root = XML::LibXML->new->parse_string($xml)->documentElement; $firmware_version = $root->findvalue("/LinkType/FirmwareVersion");
Direct Responses: 9420 | Write a response
Posted on 2008-11-25 11:38:27-08 by kumar1 in response to 9397
Re: how to get a sub node and their contents
Thanks for quick response , Actually am using the C code LibXml2. May I know the API for which we can get the Sub node Content in C.
Direct Responses: 9427 | Write a response
Posted on 2008-11-25 20:05:14-08 by eserte in response to 9420
Re: how to get a sub node and their contents
Sorry, this is a forum dedicated to Perl.
Direct Responses: 9442 | Write a response
Posted on 2008-11-27 05:49:54-08 by kumar1 in response to 9427
Re: how to get a sub node and their contents
Thank u , any how by ur suggestion using Xpath I got the solution.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.