reading root element in xml not the child

Posted by Umesha MS on Stack Overflow See other posts from Stack Overflow or by Umesha MS
Published on 2010-06-01T06:59:25Z Indexed on 2010/06/01 7:03 UTC
Read the original article Hit count: 142

Filed under:
|

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); }

© Stack Overflow or respective owner

Related posts about Xml

Related posts about qt