如何在QDomDocument中返回根元素?

时间:2012-02-13 09:20:54

标签: xml qt xml-parsing

我目前正在研究QDomDocument,我想实现几个函数,但我想只使用一个QDomDocument。所以要在工作时这样做我有时需要返回Root值。 例如,我有这样的XML;

<Root>
  <Node A>
    <Node B>
    <\Node B>
   <\Node A>
 <Root>

并且认为我正在研究Node B,但我应该怎么做才能返回?

请告诉我如何使用QDomDocument返回root值?

非常感谢

1 个答案:

答案 0 :(得分:3)

这很容易。 documentElement()返回根元素。

QDomElement QDomDocument::documentElement () const

Returns the root element of the document.