Greetings all,
A bit off topic but here is a little script I use to investigate how XML::Simple is parsing my *.xml files
This is meant to be run from the same directory that contains the xml files. Nothing novel but I find it useful.
#!/usr/bin/perl -w use strict; use XML::Simple; use Data::Dumper; #get all the .xml files from this base directory unless(opendir(CNF, '.')){ die "Unable to open directory for reading\n"; } my @config_files = sort grep { /\.xml$/ && -f "$_"} readdir(CNF); #clean up close CNF; DISPLAY: { print "Please select a file for parsing:\n"; for(my $i = 1; $i-1 < scalar(@config_files); $i++){ print "\t$i. $config_files[$i-1]\n"; } print "\n\t# "; } my ($filenum, $filename); chomp($filenum = <STDIN>); if($filenum !~ /^\d$/){ print "Please select the number\n"; goto DISPLAY; }else{ $filename = $config_files[$filenum-1]; } unless(open(CNF, $filename)){ die "unable to open XML config file". $!; }else{ my $file = do {local $/ = undef; <CNF>}; close CNF; my $xs = new XML::Simple(); my $ref = $xs->XMLin($file); print "\nXML structure (current).\n"; print Dumper($ref); print "\n"; ENDING:{ print "\n Q to quit\n"; my $key; chomp($key = <STDIN>); unless($key =~ /q/i){ goto ENDING; }else{ exit; } } }


-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

In reply to Re: using xml::simple with unknown xml structure by injunjoel
in thread using xml::simple with unknown xml structure by ctaustin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.