Is there a way to quickly validate data using Perl and XML::Simple

likeohmygosh

New Member
My XML file looks like this: \[code\]<A> <file>data1</file> <path>data2</path></A><B> <file>data3</file> <path>data4</path></B>\[/code\]So I read the data from a log file, parse it and get tags like \[code\]A\[/code\], \[code\]B\[/code\], \[code\]file\[/code\] and \[code\]path\[/code\]. Right now I use a for loop to iterate over each outer tag, and then compare against each sub tag to see if the data exists in the XML file. \[code\]$data = http://stackoverflow.com/questions/10902687/$xml->XMLin("xmlfile");foreach $e ( $data->{$outerTag} ) # outertag could be A, B{ if( $e->{file} eq $fname ) { do_something } else { return 0; } if( $e->{path} eq $pname ) { do_something } else { return 0; }}\[/code\]Is there a way whereby I don't have to use the \[code\]for\[/code\] loop.? Say I could do something like this (I am making this up):\[code\]if( $data->{$outerTag}->{$fname} ) { do_something } else { return 0; }\[/code\]
 
Back
Top