In javascript, if i want to find all tagname as “PLOT”, and get attribute value and node value for each tagname. I can use the following function.
<PLOT attr="1">a</PLOT>
<PLOT attr="2">b</PLOT>
<PLOT attr="3">c</PLOT>
<PLOT attr="4">d</PLOT>
xmlhttp.open("GET","xmltag.xml",false);
x2=xmlDoc.getElementsByTagName("PLOT");
for (i=0;i<x2.length;i++)
{
attribute=x2[i].getAttribute("attr");
value=x2[i].childNodes[0].nodeValue;
}
and it gives 1a 2b 3c 4d.
I’m trying to do the same from c/c++ with Qt,
QDomDocument doc2( "MyML" );
QFile file("../xmltag.xml");
file.close();
and what should be the next steps?
Thanks
Have a look at the documentation for
QDomDocumentandQDomElement. Basically, it’s not that different from JavaScript: