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; }
In reply to Extracting information from XML file by Nesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |