Hi, Monks
I have a program which parses the XML feed from the National Vulnerability Database (http://nvd.nist.gov). You can see a sample of the feed at http://nvd.nist.gov/download/nvdcve-2007.xml (warning: don't open this file in a browser unless you want to wait for awhile). The feed is organized by "entry", each entry being the complete report regarding a single software vulnerability. My problem is with the "vuln_soft" tag which lists each vulnerable piece of software, by product "name" and "vendor", and then version "num" and "edition". The structure of this tag is:
<nvd> <entry> ... <vuln_soft> <prod name="name1", vendor="vendor1"> <vers num="1.0" edition=/> <vers num="1.1" edition=/> ... </prod> <prod name="name2", vendor="vendor2"> <vers num="1.0" edition="ee"/> <vers num="1.1" edition="ee"/> ... </prod> ... </vuln_soft> </entry> <nvd>
This all works fine except when the name attribute for 2 <prod> tags have the same value. This is unfortunate because it's perfectly legitimate for the same "product" to be distributed by 2 different "vendors".
A real-world example of this is the vulnerability CVE-2007-5333 (from the file, above) which reports vulnerabilities in tomcat from 2 vendors, "apache" and "apache_software_foundation", each with different version lists.
... <vuln_soft> <prod vendor="apache" name="tomcat"> <vers num="4.1.10" /> ... </prod> <prod vendor="apache_software_foundation" name="tomcat"> <vers num="4.1" /> ... </prod> </vuln_soft> ...
XML::Simple won't create a list of tomcat entries, by vendor. Instead, it drops all of the tomcat "products" except the last one parsed.
Arguably this isn't well-formed XML (at least, XML::Simple complains about it when I turn on strict mode), but who am I to be arguing with the Feds? Am I going to have to start messing around with custom handlers in XML::Parser? Would that even work with this dodgy XML, since XML::Simple is already based on XML::Parser?
Thanks
Larry Barnett
In reply to How do I parse XML with repeating attribute values? by 1arryb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |