Qt 中 QXml/QDom*** api設計吐槽

昨天下午搞了一下Qt中的dom解析。發現並無java中的好用。java

1. 除了QDomDocument類之外,均沒有toString方法。我僅僅想吧QDom**->QString 只能經過QDomDocuemnt來實現node

2. 就算用QDomDocument。 須要將QDom** append到QDomDocument。就會出現下面的結果:api

    QDom**是經過此QDomDocument::create**出來的。能夠append.app

    QDom**不是經過此QDomDocument::create**出來的,QDomDocument用帶參的初始化方法初始化的。能夠appenddom

    QDom**不是經過此QDomDocument::create**出來的,QDomDocument用無參的初始化方法初始化的。不能夠append函數

3. QDomNode是全部QDom**的父類。其中appendChild()又是咱們常常用的。看官網註釋this

Appends newChild as the node's last child.

If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, then its position in the list of children is changed.

If newChild is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and appended.

If newChild is a QDomElement and this node is a QDomDocument that already has an element node as a child, newChild is not added as a child and a null node is returned.

Returns a new reference to newChild on success or a null node on failure.

Calling this function on a null node(created, for example, with the default constructor) does nothing and returns a null node.

The DOM specification disallow inserting attribute nodes, but for historical reasons, QDom accepts them anyway.

  1. 若是newChild是其餘節點的孩子,那麼重定向到此節點,若是是這個節點的孩子,則改變位置。google

    若是我僅僅想複製newChild到其餘節點。那麼我須要copy newChild,比較蛋疼須要從新new一個而後一個一個copy。blog

    ok 我知道寫個clone方法或者有api能夠調用。可是增長一個直接插入的函數難道很差麼?我幫起個名字:appendChildFocus();ci

     2. 3. 就不說了。也是限制條件。 

 

 我只關注了這些。浪費了我4個小時的時間後,而後決定用QJson OYE. 

 google了一下你們怎麼評論的。第一條就是" just confusing me!!!"  因此建議你們能不用QDom就不用。

相關文章
相關標籤/搜索