2011-05-31 57 views
1
import QtQuick 1.0 

Rectangle { 
    Component { 
    id: delegate 
     Text{text: title} 
    } 

    ListView { 
    y:10 
    id: view 
    anchors.fill: parent 
    model: model 
    delegate: delegate 
    } 


    XmlListModel { 
    id:model 
    source: "http://www.w3.org/" 
    query: "/html/head" 
    namespaceDeclarations: "declare default element namespace 'www.w3.org/1999/xhtml/';" 

    XmlRole { name: "title"; query: "title/string()" } 
    } 
} 

我希望我的模型,現在將有一個元素與標題=「萬維網聯盟(W3C)」顯示 但沒有。 model.count是零,但model.progress是1 我使用錯誤的名稱空間聲明?問題加載網頁到QML XmlListModel

千恩萬謝

帕特里克

回答

0

的命名空間必須在文件中聲明的確切命名空間。聲明的名稱空間應該是「http://www.w3.org/1999/xhtml」,而不是「www.w3.org/1999/xhtml」。

1

試試這個:

XmlRole { name: "title"; query: "title[1]/string()" } 

陣列中把一個1,表示要檢索的第一個冠軍。