Frage

I have, lets say, the following XML:

<geometry>
    <point x=0 y=0/.
    <point x=1 y=1/.
    <point x=2 y=2/.
</geometry>

And I have the following code:

QFile file(...);
QDomDocument dom;
dom.setContent(&file);
QDomElement geometry = dom.documentElement();
for( int i=0; i<geometry.childNodes().size(); ++i ) {
    std::cout << childNodes().item(i).toElement().attribute("x").toDouble() << std::endl;
}

Is it guaranted that my output will always be that below?

1.0
2.0
3.0
War es hilfreich?

Lösung

Yes, it is, because QDomNodeList returned by childNodes implements W3C's NodeList which is ordered.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top