1

我正在尝试将 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 )
4

1 回答 1

1

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

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

不是有效的 XPath 表达式。不应有尾部斜杠。

于 2012-07-24T09:19:22.907 回答