Nesh has asked for the wisdom of the Perl Monks concerning the following question:
And my code goes as<?xml version="1.0"?> <reports> <report> <report-name>POSM1M029</report-name> <source-file id='1'> <source-file-path></source-file-path> </source-file> <destination-file id='1'> <destination-file-path></destination-file-path> </destination-file> </report> <report> <report-name>CNAM1D001</report-name> <source-file id='1'> <source-file-path>G:\Interfaces\ApplnData\DENVER_TRAN\Navi +Sys\Input\EXPORT_CFM.txt</source-file-path> </source-file> <destination-file id='1'> <destination-file-path>L:\Enterprise Reports\Input Files\ +ipCNAM1D001Confirm.txt</destination-file-path> </destination-file> <source-file id='2'> <source-file-path>G:\Interfaces\ApplnData\DENVER_TRAN\Navi +sys\Input\EXPORT_ERR.txt</source-file-path> </source-file> <destination-file id='2'> <destination-file-path>L:\Enterprise Reports\Input Files\ +ipCNAM1D001Error.txt</destination-file-path> </destination-file> </report> </reports>
I want to get the report names (POSM1M029,CNAM1D001 etc. Please tell me where I am wrong. Thanks for your help.use Win32::OLE qw(in with); #my $xml_file = 'file.xml'; my $DOM_document = Win32::OLE->new('MSXML2.DOMDocument') or die "new() + failed"; $DOM_document->{async} = "False"; $DOM_document->{validateOnParse} = "True"; my $boolean_Load = $DOM_document->Load("file.xml"); if (!$boolean_Load) { die "topten.xml did not load"; } my $Reports = $DOM_document->DocumentElement(); my $Report = $Reports->childNodes(); foreach my $Event (in $Report) # make sure you include the 'in' { my $temp =$Event->Attributes->getNamedItem("report-name")->{text}; print $temp; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting information from XML file
by Cody Pendant (Prior) on Apr 05, 2005 at 02:28 UTC | |
by Nesh (Beadle) on Apr 14, 2005 at 22:23 UTC | |
by Cody Pendant (Prior) on Apr 15, 2005 at 00:01 UTC | |
|
Re: Extracting information from XML file
by ikegami (Patriarch) on Apr 05, 2005 at 00:50 UTC | |
|
Re: Extracting information from XML file
by mirod (Canon) on Apr 05, 2005 at 08:13 UTC |