Hi Monks!

I am working on a program that has to read a large xml file, I have a sample here of both, Perl and xml file, and its driving me crazy, I can get an attribute from a duplicated node into my variable to print, where and what am I missing here please!
Thanks, and here is a sample code of what I am trying to do:

#!/perl/bin/perl use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use XML::XPath; use XML::XPath::XMLParser; print header(); my $xp = XML::XPath->new(filename => 'test_x.xml'); foreach my $row ($xp->findnodes('/HOME/Trans')) { # extract from the XML my $trans = $row->find('//@ID')->string_value; my $cert = $row->find('Cert')->string_value; my $cert = $row->find('/AD/@XREF')->string_value; my $fname = $row->find('AD/FName')->string_value; my $lname = $row->find('AD/LName')->string_value; my $bdate = $row->find('AD/BDate')->string_value; my $no = $row->find('AD/No')->string_value; my $state = $row->find('AD/State')->string_value; my $ssss = $row->find('AD/SSSS')->string_value; my $train = $row->find('AD/Train')->string_value; my $volume = $row->find('AD/Volume')->string_value; my $cno = $row->find('AD/CNo')->string_value; my $id = $row->find('AD/ID')->string_value; print "1-$trans - 2-$cert - 3-$cert - 4-$fname - 5-$lname - 6-$bdate - + 7-$no - 8-$state - 9-$ssss - 10-$train - 11-$volume - 12-$cno - + 13-$id\n"; } =comment test_x.xml <?xml version="1.0"?> <HOME> <Trans ID="0164754"> <Cert>8280164754</Cert> <AD XREF="DELTA1"> <FName>Joe</FName> <LName>Frost</LName> <BDate>19650420</BDate> <No>X0000000</No> <State>RI</State> <Date>19980401</Date> <SSSS>07</SSSS> <Train>N</Train> <Volume>N</Volume> </AD> <AD XREF="DELTA2"> <FName>MARY </FName> <LName>FROST</LName> <BDate>19861107</BDate> <No>Y0000000</No> <State>NY</State> <Date>20030824</Date> <SSSS>00</SSSS> <Train>Y</Train> <CNo>153</CNo> <ID>WC204338</ID> <Volume>N</Volume> </AD> <Total>111</Total> </Trans> </HOME> =cut

In reply to XML Path and Perl by Anonymous Monk

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.