Answer the question
In order to leave comments, you need to log in
How is a node different from an element in a QtXMLDocument?
Parsing an example from Qt
QDomNode n = docElem.firstChild();
while(!n.isNull()) {
QDomElement e = n.toElement(); // пробуем преобразовать узел в элемент.
if(!e.isNull()) {
cout << e.tagName() << endl; // узел действительно является элементом.
}
n = n.nextSibling();
}
<?xml version="1.0" encoding="utf-8"?>
<docroot>
<node id = "1">
<intnode id = "1" name = "element1">element 1</intnode>
<intnode id = "1" name = "element2">element 2</intnode>
<intnode id = "1" name = "element3">element 3</intnode>
</node>
<node id = "2">
<intnode id = "2" name = "element1">element 4</intnode>
<intnode id = "2" name = "element2">element 5</intnode>
<intnode id = "2" name = "element3">element 6</intnode>
</node>
<node id = "3">
<intnode id = "3" name = "element1">element 7</intnode>
<intnode id = "3" name = "element2">element 8</intnode>
<intnode id = "3" name = "element3">element 9</intnode>
</node>
</docroot>
Answer the question
In order to leave comments, you need to log in
All parts of XML are nodes (document itself, elements, attributes, etc.). An element is one particular kind of node. In XML text representation, an element is defined by start and end tags and has a (tagname), namespace, attributes, text content, and child nodes, respectively.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question