简体   繁体   中英

doc.documentElement() does not return root element?

I am currently working on a XML parser and I am using Qt to make it. Actually I have coded lots of things and functions but now I got a weird problem. When I make;

QDomElement root = doc.documentElement();

It never return root element. I debugged it and I can see doc has a value but never returns root element. What can be the problem ?

Thank you all

If you have created an empty QDomDocument it has no root element. You need to create one:

QDomElement root = doc.createElement("myroot");
doc.appendChild(root);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM