Hi I am working on an application which reads XML file. Here I am trying to read "name" node under the "a"node not under the node "b". When I tried to read the root "name" node I get both nodes. Please help me to solve the problem. Bellow is the sample.
<a>
<x>rrr</X>
<b>
<name> 123 </name>
</b>
<name> main </name>
<c>yyyy</c>
</a>
QDomDocument mDocument;
QDomElement mDocumentElement;
if (!mDocument.setContent(file.readAll()))
{
return ;
}
mDocumentElement = mDocument.documentElement();
QDomNodeList list = mDocumentElement.elementsByTagName("a").at(0).toElement().elementsByTagName("name");
int count = list.count();
for (int i = 0; i < count; i++)
{
QString str = list.at(i).nodeValue();
QMessageBox::information(this, "text", str, QMessageBox::Yes, 0);
}