在将网页加载到QML XmlListModel时出现问题

|
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()\" }
  }
}
我希望我的模型现在包含一个标题为“ World Wide Web Consortium(W3C)\”的Element。 但没有显示任何内容。 model.count为零,但model.progress为1 我使用了错误的名称空间声明吗? 非常感谢 帕特里克     
已邀请:
        尝试这个:
XmlRole { name: \"title\"; query: \"title[1]/string()\" }
将1放入数组中,表示您要检索第一个标题。     
        名称空间必须是文档中声明的确切名称空间。代替\“ www.w3.org/1999/xhtml \”,声明的名称空间应为\“ http://www.w3.org/1999/xhtml \”。     

要回复问题请先登录注册