将网页加载到QML XmlListModel时出现问题
我希望我的模型现在包含一个元素,标题为“万维网联盟(W3C)” 但是什么也没有显示。model.count为零,但model.progress为1 我是否使用了错误的名称空间声明 非常感谢将网页加载到QML XmlListModel时出现问题,qml,Qml,我希望我的模型现在包含一个元素,标题为“万维网联盟(W3C)” 但是什么也没有显示。model.count为零,但model.progress为1 我是否使用了错误的名称空间声明 非常感谢 Patrick名称空间必须是文档中声明的确切的名称空间。声明的名称空间应该是“http://www.w3.org/1999/xhtml”,而不是“www.w3.org/1999/xhtml”http://www.w3.org/1999/xhtml“名称空间必须是文档中声明的确切的名称空间。声明的名称空间应该是
Patrick名称空间必须是文档中声明的确切的名称空间。声明的名称空间应该是“http://www.w3.org/1999/xhtml”,而不是“www.w3.org/1999/xhtml”http://www.w3.org/1999/xhtml“名称空间必须是文档中声明的确切的名称空间。声明的名称空间应该是“http://www.w3.org/1999/xhtml”,而不是“www.w3.org/1999/xhtml”http://www.w3.org/1999/xhtml“试试这个:
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()" }
}
}
将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()" }
}
}
将1放入数组中,表示要检索第一个标题