tried the package XML::SIMPLE and I can read out an XML but when I try to read my data by just selection the info I need it wont return a value.

What? Also, your XML isn't valid.

$ perl -MXML::Simple -MDDS -le" Dump( XMLin( shift ))" quat.xml $HASH1 = { JOB => { GROUP => 'xp_maint', NODEID => 'localhost', QUANTITATIVE => [ { NAME => 'QR1-INIT', QUANT => 1 }, { NAME => 'QR2-NODEID', QUANT => 1 }, { NAME => 'QR3-GROUP', QUANT => 1 } ], USE_INSTREAM_JCL => 0 } };
$ cat quat.xml <?xml version='1.0' encoding='ISO-8859-1' ?> <!DOCTYPE DEFJOB SYSTEM "/aa/em/ddd/e62xstf3/resource/defjob.dtd"> <DEFJOB > <JOB GROUP="xp_maint" NODEID="localhost" USE_INSTREAM_JCL="0" > <QUANTITATIVE NAME="QR1-INIT" QUANT="1" /> <QUANTITATIVE NAME="QR2-NODEID" QUANT="1" /> <QUANTITATIVE NAME="QR3-GROUP" QUANT="1" /> </JOB> </DEFJOB> $ perl -MXML::Simple -le " print XMLout( XMLin( shift ), qw! RootName +DEFJOB XMLDecl ! , qq[<?xml version=\x221.0\x22 encoding=\x22ISO-8859 +-1\x22 ?>\n<!DOCTYPE DEFJOB SYSTEM \x22/aa/em/ddd/e62xstf3/resource/d +efjob.dtd\x22>] )" quat.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE DEFJOB SYSTEM "/aa/em/ddd/e62xstf3/resource/defjob.dtd"> <DEFJOB> <JOB GROUP="xp_maint" NODEID="localhost" USE_INSTREAM_JCL="0"> <QUANTITATIVE NAME="QR1-INIT" QUANT="1" /> <QUANTITATIVE NAME="QR2-NODEID" QUANT="1" /> <QUANTITATIVE NAME="QR3-GROUP" QUANT="1" /> </JOB> </DEFJOB>

1. What would be the best package to use? XML::SIMPLE?

It depends. You can't go wrong with XML::Twig, XML::Rules, XML::LibXML...

I was thinking to read the data into an array, then to see if any "QUANTITATIVE NAME" is used, if not I would create new ones with the GROUP / NODEID

Um, try it and you'll see why its a bad idea, but if you can make it work, or like suffering .... to each his own :)


In reply to Re: Reading and Manipulation XML Files by Anonymous Monk
in thread Reading and Manipulation XML Files by gizmojunkee

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.