QML中的错误XPST0003

时间:2012-07-24 06:54:14

标签: xml qt qml

我正在尝试将xmlrpc对wordpress的调用结果解析为xmllistmodel。模型在这里:

XmlListModel {
        id: dataModel
        query: "/methodResponse/params/param/value/array/data/value/"
        XmlRole {name: "postId"; query:"struct/member[1]/value/int/number()"; isKey: true}
        XmlRole {name: "title"; query: "struct/member[6]/value/string()"}
}

这是xml数据:

<methodResponse>
    <params>
        <param>
            <value>
                <array>
                    <data>
                        <value>
                            <struct>
                                <member><name>ID</name><value><int>358</int></value></member>
                                <member><name>post_author</name><value><string>3</string></value></member>
                                <member><name>post_date</name><value><string>2008-09-05 00:27:25</string></value></member>
                                <member><name>post_date_gmt</name><value><string>2008-09-05 07:27:25</string></value></member>
                                <member><name>post_content</name><value><string>Some content</string></value></member>
                                <member><name>post_title</name><value><string>Readability Test</string></value></member>
                            </struct>
                        </value>
                        <value>
                            <struct>
                                <member><name>ID</name><value><int>188</int></value></member>
                                <member><name>post_author</name><value><string>3</string></value></member>
                                <member><name>post_date</name><value><string>2008-09-04 23:02:20</string></value></member>
                                <member><name>post_date_gmt</name><value><string>2008-09-05 06:02:20</string></value></member>
                                <member><name>post_content</name><value><string>Some content</string></value></member>
                                <member><name>post_title</name><value><string>Layout Test</string></value></member>
                            </struct>
                        </value>
                    </data>
                </array>
            </value>
        </param>
    </params>
</methodResponse>

那么问题是什么,以及导致这些错误的原因:

Error XPST0003 in file:///usr/bin/qmlviewer, at line 1, column 62: syntax error, unexpected end of file
Error XPST0003 in file:///usr/bin/qmlviewer, at line 2, column 40: syntax error, unexpected )

1 个答案:

答案 0 :(得分:1)

我不知道WordPress,但它可能会抱怨,因为:

query: "/methodResponse/params/param/value/array/data/value/"

不是有效的XPath表达式。应该没有尾随斜杠。