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


my xml file looks this:

<a>  <file>data1</file>  <path>data2</path> </a>  <b>   <file>data3</file>   <path>data4</path> </b> 

so read data log file, parse , tags a, b, file , path. right use loop iterate on each outer tag, , compare against each sub tag see if data exists in xml file.

$data = $xml->xmlin("xmlfile");  foreach $e ( $data->{$outertag} ) # outertag a, b {  if( $e->{file} eq $fname ) { do_something } else { return 0; }  if( $e->{path} eq $pname ) { do_something } else { return 0; } } 

is there way whereby don't have use for loop.? (i making up):

if( $data->{$outertag}->{$fname} ) { do_something } else { return 0; } 

as long xml::simple has built rational structure data can write

if ( $data->{$outertag}{file} eq $fname ) { ... } 

but, depending on want data, may better off using better xml parser, xml::libxml.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -