From what I can decipher from your powershell code you want to extract the work node with attribute eu and write out to an html file.

One way would be using XML::Twig::XPath to process the xml and HTML::Template to create the html file

For example :

#!perl use strict; use XML::Twig::XPath; use LWP::Simple; use HTML::Template; use Data::Dump 'pp'; # XML parser my $twig = XML::Twig::XPath->new( twig_roots => { '/find/find/work[@eu]' => \&work, }, ); # get and process xml my @rows = (); my $URL = 'http://www.geocities.ws/arenas/xml/find.xml'; #$twig->parse( *DATA ); #test with __DATA__ records $twig->parse( LWP::Simple::get( $URL ) ); pp \@rows; # prepare html template and parameters my $template = get_template(); my $t = HTML::Template->new( scalarref => \$template ); $t->param( EU => \@rows ); # create html open my $fh_out,'>','val.html' or die "$!"; print $t->output( print_to => $fh_out ); close $fh_out; # extract data from work node sub work { my ($twig,$el) = @_; for my $ch ($el->children){ my %rec = ( 'name' => $ch->name ); $rec{$_} = $ch->att($_) for ('a'..'f'); push @rows,\%rec; } }
# or put in file sub get_template { return <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Title</title> </head> <body> <table border="1" cellspacing="0" cellpadding="3"> <tr align="center"> <td>Name</td> <td>a</td> <td>b</td> <td>c</td> <td>d</td> <td>e</td> <td>f</td> </tr> <TMPL_LOOP EU> <tr> <td><TMPL_VAR name></td> <td><TMPL_VAR a></td> <td><TMPL_VAR b></td> <td><TMPL_VAR c></td> <td><TMPL_VAR d></td> <td><TMPL_VAR e></td> <td><TMPL_VAR f></td> </tr> </TMPL_LOOP> </table> </body> </html> EOF } __DATA__ <?xml version="1.0"?> <find> <find group="1"> <work eu="4"> <root1 a="8554" b="1248" c="2496" d="1248" e="1536" f="1702"/> <root2 a="5812" b="1300" c="1001" d="0" e="1431" f="1600"/> <root3 a="8001" b="1118" c="2306" d="1018" e="1500" f="2002"/> <root4 a="7112" b="2048" c="1996" d="1348" e="0" f="1711"/> </work> <work Nus="9"> <root1 a="8230" b="1203" c="1121" d="1112" e="0" f="1090"/> <root2 a="8230" b="0" c="0" d="3112" e="0" f="2090"/> </work> <work Mus="2"> <root1 a="5928" b="1313" c="1117" d="1172" e="1112" f="1114"/> </work> <work Sus="7"> <root1 a="7355" b="1923" c="1312" d="1146" e="1534" f="1240"/> </work> </find> <find group="2"> <work Eas="1"> <root1 a="6814" b="1159" c="1696" d="1248" e="1200" f="1411"/> </work> <work Pas="3"> <root1 a="4617" b="1126" c="1155" d="1122" e="0" f="1144"/> </work> <work Mas="11"> <root1 a="4987" b="1477" c="1118" d="1301" e="0" f="1001"/> </work> <work Sas="21"> <root1 a="7202" b="1644" c="1200" d="1165" e="2034" f="1099"/> </work> </find> </find>
poj

In reply to Re: Select Node by poj
in thread Select Node by Arenas

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.