Parsing emoty fields XML using perl
by Alok Sharma other posts by this author
May 14 2009 12:11PM messages near this date
view in the new Beta List Site
Re: Accessing name part of attributes using XML::LIbXML::Attr class
|
Re: Parsing emoty fields XML using perl
& XSLT Hi,
I need some tips to parse some piece of xml using perl (both depicted below). I need to extr
act the TOPNAME and MAPREF fields. Please suggest.
Thanks,
Alok
The XML code is :
<TEST:component xmlns:ip="IP" xmlns:nx="IP" xmlns:s="1.2" xmlns:xsi="nstance">
<TEST:vendor> VENDOR</TEST:vendor>
<TEST:library> nxCtoIp</TEST:library>
<TEST:name> NAME</TEST:name>
<TEST:version> 4.1.0</TEST:version>
<TEST:busInterfaces>
<TEST:busInterface TEST:id="MYID" TEST:resolve="user">
<TEST:name> MYNAME</TEST:name>
<TEST:busType TEST:library="nxCtoBus" TEST:name="TOPNAME" TEST:vendor="VENDOR" TEST:
version="1.0"/>
<TEST:slave>
<TEST:AMAPRef TEST:AMAPRef="MAPREF"/>
</TEST:slave>
<TEST:connection> required</TEST:connection>
<TEST:signalMap>
Perl code I tried :
foreach my $component ($ipxml-> getElementsByTagName('TEST:component')) {
my $cname = ($component-> getElementsByTagName('TEST:name'))[0]->getFirstChild->getData();
&log("component name = $cname\n") if $debug;
print FILENAME "// Component = $cname\n";
MAPS : foreach my $busInterface ($component-> getElementsByTagName('TEST:busInterface')) {
my $busname = ($busInterface-> getElementsByTagName('TEST:name'))[0]->getFirstChild->getD
ata();
my $bustype = ?? Need to get TOPNAME ???
??? Also need to get MAPREF somehow ???
Thread:
Alok Sharma
Jenda Krynicky
Wayne Simmons
|