【问题标题】:Read XML with Oracle XMLTYPE: LPX-00210: expected '"' instead of '\'使用 Oracle XMLTYPE 读取 XML:LPX-00210:预期为 '"' 而不是 '\'
【发布时间】:2016-07-25 11:21:03
【问题描述】:

我正在尝试使用 XMLTYPE 在 ORACLE 中读取 XML。

当使用下面的 xml 时,我得到了消息 LPX-00210: expected '"' 而不是 '\'

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<arrayofaccesstoken xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
<accesstoken>
<id>0</id>
<controller>fs</controller>
<view>fview</view>
<role>1000</role>
<rights>30</rights>
</accesstoken>

当第一条拖线时,代码工作得很好

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<arrayofaccesstoken xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">

省略。

【问题讨论】:

    标签: xml plsql oracle11g


    【解决方案1】:

    您不必在 oracle 字符串中转义双引号,因为 oracle 中的所有字符串都用单引号括起来。

    这个 XML 应该可以正常工作。

    <?xml version="1.0" encoding="utf-16"?>
    <arrayofaccesstoken xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <accesstoken>
            <id>0</id>
            <controller>fs</controller>
            <view>fview</view>
            <role>1000</role>
            <rights>30</rights>
        </accesstoken>
    </arrayofaccesstoken>
    

    我修复的其他东西 -

    1. 最后没有结束标记。
    2. 在关闭 xmlns:xsi 的双引号之后和 xmlns:xsd 之前需要有一个空格。

    【讨论】:

    • 立即获取 LPX-00230:在名称或 Nmtoken 中发现无效字符 10 (U+000A)
    • 它可能不支持换行符作为换行符。您可以删除所有换行符以使其正常工作,或者执行我在您的 XML 中列出的之前对您有用的更改,您应该会很好。
    • 您的 XML 是什么样的?该错误表示元素标记内有换行符。请检查一下。
    • 你成就了我的一天。我正在努力解释 wat 10(u+000a) 的意思。它是 xml 中的一个 TYPO。
    猜你喜欢
    • 1970-01-01
    • 2016-02-06
    • 2019-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    相关资源
    最近更新 更多