Hello, I am trying to parse a XML file, but I get this error Not a HASH reference at ./parser.pl line 42

At Line 42,

print REPORT '<td>' . $e->{desc}->{descript}->{content} . '</td><td><br>';
When I checked the line that cause this issue in the XML file, I can see maybe because the tag is repeated. Not really sure!
<entry type="CVE" severity="Medium" seq="1999-0453" published="1999-01 +-01" name="CVE-1999-0453" modified="2008-09-05" CVSS_version="2.0" CV +SS_vector="(AV:N/AC:L/Au:N/C:P/I:N/A:N)" CVSS_score="5.0" CVSS_impact +_subscore="2.9" CVSS_exploit_subscore="10.0" CVSS_base_score="5.0"> <desc> <descript source="cve">An attacker can identify a CISCO device b +y sending a SYN packet to port 1999, which is for the Cisco Discovery + Protocol (CDP).</descript> <descript source="nvd">Please see the following link for more in +formation:http://seclists.org/bugtraq/1999/Jan/0215.html</descript> </desc>
I think I should add a keyattr, but I don't know how! I think it should be something like this KeyAttr    => {descript=>"+source"} I have already this part in the code
$data = $xml->XMLin( $ARGV[0], KeyAttr => { cve => 'entry'}, ForceArray => [ 'cve', 'ref' ] );
Thanks.


In reply to XML parsing by asa

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.