Y
Y
Yu Yu2015-02-21 16:55:54
Qt
Yu Yu, 2015-02-21 16:55:54

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

And where in the XML representation will the node be and where are the elements?
How do they generally differ?
<?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

2 answer(s)
P
Pavel, 2015-03-27
@xztau

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.

A
Andrew, 2017-11-04
@daaner

If you took a new one, the laptop is still under warranty. Change it or take it in for repair under warranty, let them sort it out themselves

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question