reading root element in xml not the child
- by Umesha MS
Hi I am working on an application which reads XML file. Here I am trying to read the node under the not under the node .
When I tried to read the I get both.
Please help me to solve the problem.
Bellow is the sample.
"a"
"x"..."/X"
"b"
"name" 123 "/name"
"/b"
"name" main "/name"
"c".."/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);
}