문제

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
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top