【问题标题】:Get Name tag from XML从 XML 中获取名称标签
【发布时间】:2015-01-10 17:45:55
【问题描述】:
<Attribute DisplayOrder="-1">
    <Categories>
<Category Name="Properties">
<Properties>
<Property Name="Visible" Value="True"/>
<Property Name="Enabled" Value="False"/>
<Property Name="Mandatory" Value="True"/>
<Property Name="Button" Value="True"/>
<Property Name="Label">
                    <Locales>
                        <Locale Name="en" Value="Device Selection Button"/>
                    </Locales>
                </Property>
<Property Name="Style" Value=""/>
<Property Name="ShowHelpText" Value="False"/>
<Property Name="EventChange" Value="False"/>
<Property Name="Mask" Value=""/>
<Property Name="NumberOfLines" Value="1"/>
<Property Name="EditType" Value="0"/>
<Property Name="ButtonCaption">
                    <Locales>
                        <Locale Name="en" Value="Select Device"/>
                    </Locales>
                </Property>
</Properties>
</Category>
<Category Name="External Functions">
<Properties>
<Property Name="function" Value="SelectEquipmentByCategory"/>
<Property Name="actionType" Value="SetOne"/>
<Property Name="Parameters" Value="Devices_Cat,4355608"/>
</Properties>
</Category>
</Categories>
</Attribute>

我有这个 XML 并且在 SQL 中我想要选择设备的值。

查询:

SELECT EXTRACTVALUE(xmltype(display_info_xml), '/Attribute/Categories/Properties/Property[@Name="Label"]/Locales/Locale[@Name="en"]/Value') 
FROM table

现在查询返回空白。 我试图创建所有 XPATH 但没有用。 请帮忙。

编辑:

更新查询:

/Attribute/Categories/Category[@Name="Properties"]/Properties/Property[@Name="Label"]/Locales/Locale[@Name="en"]/Value

仍然失败,没有数据返回。

【问题讨论】:

    标签: sql xpath


    【解决方案1】:

    我觉得你应该这样试试

    SELECT EXTRACTVALUE(xmltype(display_info_xml), '//Property[@Name="ButtonCaption"]/Locales/Locale[@Name="en"]/Value') 
    FROM table
    

    SELECT EXTRACTVALUE(xmltype(display_info_xml), '/Attribute/Categories/Category/Properties/Property[@Name="ButtonCaption"]/Locales/Locale[@Name="en"]/Value') 
    FROM table
    

    你写你想要的值作为选择设备在你的例子中你指向作为设备选择按钮的值

    【讨论】:

      【解决方案2】:

      您缺少Category 标签。

      此外,Value 属性应以@ 开头。 (http://www.tizag.com/xmlTutorial/xpathattribute.php)

      正确的 XPATH 是 /Attribute/Categories/Category/Properties/Property[@Name="Label"]/Locales/Locale[@Name="en"]/@Value

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-27
        • 1970-01-01
        • 1970-01-01
        • 2022-11-25
        • 1970-01-01
        相关资源
        最近更新 更多