Mysql extractvalue函数从xml内容中检索xml片段

时间:2015-03-30 21:47:31

标签: php mysql xml

我的xml内容“CommandDefinition”=

<command category="213" id="3" type="om">
    <name>CMD_1</name>
    <description>this is the desc</description>
    <parameter pos_index="1">
        <description>device index</description>
        <state>1</state>
    </parameter>
</command>
<command category="213" id="4" type="om">
    <name>CMD_2</name>
    <description>This parameter belongs to FAPService.{i}.Capabilities.</description>
    <parameter pos_index="1">
        <description>device index</description>
        <state>1</state>
        </parameter>
</command>

我正在尝试检索命令标记的整个节点值,其中name属性保存值“CMD_2”。即检索值应如下所示:

<command category="213" id="4" type="om">
    <name>CMD_2</name>
    <description>This parameter belongs to FAPService.{i}.Capabilities.</description>
    <parameter pos_index="1">
        <description>device index</description>
        <state>1</state>
        </parameter>
</command>

我试过以下:

ExtractValue(CommandDefinition,'// command [name =“CMD_2”]')

但是这会给我一个空字符串。有什么想法吗? THX

1 个答案:

答案 0 :(得分:0)