lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Aug 8, 2016 at 4:57 PM, TW <zupftom@googlemail.com> wrote:
I personally love XPath for querying XML.  I never tried it, but maybe
LuaXPath is an option for you?

  https://luarocks.org/modules/basiliscos/luaxpath

Thanks, but is that package still maintained? There is no xpath.lua file. I'm open to any other solutions as well.

 


2016-08-08 15:03 GMT+02:00 Gary Madarm <gmadarm@gmail.com>:
> I am trying to parse an XML file
> (https://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-2013.xml.gz) and
> access specific elements (vuln:cve-id, cvss:score and cpe-lang:fact-ref). I
> am using the SLAXML library (https://github.com/Phrogz/SLAXML) to parse the
> file. I can access element values by specifying the exact location, e.g to
> access the CVSS score for the first entry run:
>
>> return doc.root.el[1].el[12].kids[2].kids[2].kids[1].value
> 4.3
>
> However, because not all entries contain the same number of children
> elements I can't simply rotate the element ID to access the CVSS score for
> the entire document. How can I access the document via element names
> instead? Is there a better approach to parsing out the three values I need?
>
> thanks!
>