Hi,
I'm trying to parse an xml file and when I try to read through the first element, I'm not getting all the corresponding attributes of that element. Only a few are getting noticed. Would be of great help if someone help me in finding the issue.

My xml file is
Qt Code:
  1. <nvd xmlns="http://scap.nist.gov/schema/feed/vulnerability/2.0" xmlns:cpe-lang="http://cpe.mitre.org/language/2.0" xmlns:vuln="http://scap.nist.gov/schema/vulnerability/0.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:scap-core="http://scap.nist.gov/schema/scap-core/0.1" xmlns:cvss="http://scap.nist.gov/schema/cvss-v2/0.2" xmlns:patch="http://scap.nist.gov/schema/patch/0.1" nvd_xml_version="2.0" xsi:schemaLocation="http://scap.nist.gov/schema/patch/0.1 http://nvd.nist.gov/schema/patch_0.1.xsd http://scap.nist.gov/schema/scap-core/0.1 http://nvd.nist.gov/schema/scap-core_0.1.xsd http://scap.nist.gov/schema/feed/vulnerability/2.0 http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd" pub_date="2011-10-23T16:00:27">
  2. <entry id="CVE-2016-4172">
  3. <vuln:vulnerable-configuration id="http://nvd.nist.gov/">
  4. <cpe-lang:logical-test operator="AND" negate="false">
  5. <cpe-lang:logical-test operator="OR" negate="false">
  6. <cpe-lang:fact-ref name="cpe:/a:adobe:flash_player:11.2.202.626" />
  7. </cpe-lang:logical-test>
  8. <cpe-lang:logical-test operator="OR" negate="false">
  9. <cpe-lang:fact-ref name="cpe:/o:linux:linux_kernel" />
  10. </cpe-lang:logical-test>
  11. </cpe-lang:logical-test>
  12. </vuln:vulnerable-configuration>
  13. </entry>
  14. </nvd>
To copy to clipboard, switch view to plain text mode 

My code to to find the attributes of an element -
Qt Code:
  1. #include <QCoreApplication>
  2. #include <QDebug>
  3. #include <QXmlStreamReader>
  4. #include <QFile>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QCoreApplication a(argc, argv);
  9.  
  10. QFile file("C:/Users/shravan/Documents/rahul_prac/test.xml");
  11. if(!file.open(QFile::ReadOnly)) { qDebug() << "Cannot read file" << file.errorString(); }
  12.  
  13. QXmlStreamReader xml(&file);
  14. while(!xml.atEnd())
  15. {
  16. if(xml.isStartElement())
  17. {
  18. if(xml.name() == "nvd")
  19. {
  20. int count = xml.attributes().count();
  21. for(int i = 0; i < count; i++)
  22. {
  23. qDebug() << xml.attributes().at(i).name().toString()
  24. << ": "
  25. << xml.attributes().at(i).value().toString();
  26. qDebug() << "\n\n";
  27. }
  28. }
  29. }
  30. xml.readNextStartElement();
  31. }
  32.  
  33. return a.exec();
  34. }
To copy to clipboard, switch view to plain text mode 

My result is
Qt Code:
  1. "nvd_xml_version" : "2.0"
  2.  
  3. "schemaLocation" : "http://scap.nist.gov/schema/patch/0.1 http://nvd.nist.gov/schema/patch_0.1.xsd http://scap.nist.gov/schema/scap-core/0.1 http://nvd.nist.gov/schema/scap-core_0.1.xsd http://scap.nist.gov/schema/feed/vulnerability/2.0 http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd"
  4.  
  5. "pub_date" : "2011-10-23T16:00:27"
To copy to clipboard, switch view to plain text mode 

There are more attributes in the xml than what I get in the result. I'm thinking what could possibly be wrong. Thanks.

Thanks