Thanks for the help guys, I was almost there, when requirements changed slightly. The above code you gusy gave me worked except in the following instance:
<authenticationReports> <generatedTime>Tue Sep 29 07:07:34 PDT 2009</generatedTime> <appDeploymentFile name="app-deployment.properties.hklcp.trading"> <application name="hk"> <urlInfo> <url>a/b/hk/accts_subscription</url> <otherPrereq>HKPwdPreReq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/hk/accts_forms</url> <otherPrereq>HKPwdPreReq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/hk/custtradingpage</url> <otherPrereq>BasicPrereq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/hk/accts_userinfo</url> <otherPrereq>HKPwdPreReq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/hk/headermain</url> </urlInfo> <urlInfo> <url>a/b/hk/custservicepage</url> </urlInfo> <urlInfo> <url>a/b/hk/accts_transfermoney</url> <otherPrereq>HKPwdPreReq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/hk/userprereq</url> </urlInfo> <urlInfo> <url>a/b/hk/indices_us</url> </urlInfo> <urlInfo> <url>a/b/hk/homeloggedmessage</url> </urlInfo> <urlInfo> <url>a/b/hk/lead</url> </urlInfo> <urlInfo> <url>a/b/hk/orderviewmin</url> </urlInfo> <urlInfo> <url>a/b/hk/accts_changelogin</url> <otherPrereq>SessionPreReq</otherPrereq> </urlInfo> </application> <application name="intl"> <urlInfo> <url>a/b/intl/quotesandresearch</url> </urlInfo> <urlInfo> <url>a/b/intl/intltablesubnavviewcomponent</url> </urlInfo> <urlInfo> <url>a/b/intl/intltablemetaviewcomponent</url> </urlInfo> <urlInfo> <url>a/b/intl/disclaimer</url> </urlInfo> <urlInfo> <url>a/b/intl/headermain</url> </urlInfo> <urlInfo> <url>a/b/intl/indices_us</url> </urlInfo> <urlInfo> <url>a/b/intl/lead</url> </urlInfo> <urlInfo> <url>a/b/intl/selectlanguage</url> </urlInfo> <urlInfo> <url>a/b/intl/get-screen</url> <otherPrereq>BasicPrereq</otherPrereq> </urlInfo> <urlInfo> <url>a/b/intl/page_f</url> </urlInfo> <urlInfo> <url>a/b/intl/basicprereq</url> </urlInfo> <urlInfo> <url>a/b/intl/page</url> <otherPrereq>BasicPrereq</otherPrereq> </urlInfo> </application> </appDeploymentFile> </authenticationReports>
The following code reads the <appDeploymentFile> URL's but only for the first section of <application> IOW, I get all the URL's for the section <application name ="hk"> but none for the <application name ="intl">. Here's my code now:
sub AFXMLtoEM { print "Slurping $AFXML...."; my $TWIG = new XML::Twig ( twig_handlers => {'appDeploymentFile' = +> \&parseURL} ); #my $TWIG = new XML::Twig ( twig_handlers => {'appDeploymentFile/a +pplication' => \&parseURL} ); $TWIG -> parsefile ($AFXML) or die "Can't open $AFXML\n" ; $TWIG->flush; # Now we want to change every value from the XML name to an EM ins +tance identifier #print Dumper(\%AFURLS); exit 1; while ((my $K, my $ITEM) = each %AFURLS) { my ($G1,$G2,$APP,$INST) = split /\./,$ITEM,4; unless ($APP eq "") { $ITEM = "prd:" . $APP . ":web:" . $INST; } #Cheesy kludge - fiox when Durai confirms $AFURLS{$K} = $ITEM; } print scalar keys %AFURLS, " records slurped in.\n"; } sub parseURL { my ($T, $ADEP) = @_; my $NAME = $ADEP->att('name'); for my $URLI ($ADEP->first_child('application')->children('urlInfo +')) { #for my $URLI ($ADEP->children('urlInfo')) { # leading slash added for matching SM filters $AFURLS{ "/" . $URLI->first_child('url')->text() } = $NAME; } #$ADEP->flush; }
How can I 1. Get all URL's in any given <appDeploymentFile> section and 2. append the <application> NAME value to the end of the $NAME (value) of the Hash? I can then parse it later. I played with various child/next_child, etc parameters, and just ain't grokking it yet. Thanks for the input. First time, I've tried to use XML::Twig before... XML::Simple had always met my needs.

In reply to Re^2: XML::Twig help please by Binford
in thread XML::Twig help please by Binford

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.