首页 > 解决方案 > xpath(未知,字符不同)不存在

问题描述

我正在尝试从 PostgreSQL 表事件数据中获取一些数据

                              Table public.incidents_data
  Column   |          Type           | Modifiers | Storage  | Stats target | Description
-----------+-------------------------+-----------+----------+--------------+-------------
 mib_name  | character varying(64)   |           | extended |              |
 timestamp | bigint                  | not null  | plain    |              |
 node_id   | bigint                  | not null  | plain    |              |
 id        | bigint                  | not null  | plain    |              |
 xml_data  | character varying(4096) |           | extended |              |
 cause     | character varying(128)  |           | extended |              |

数据位于 xml_data 列中,具有以下 XML 布局。

<Incident>
<ExtraInformation>
<SslState>error</SslState>
<RemoteLocalTuple>Remote Ip:Port 1.1.1.1:46537  &lt;---&gt;  Local Ip:Port 2.2.2.2:5061</RemoteLocalTuple>
</ExtraInformation>
<StandardInfo>
<Cause>error:14094415:SSL routines:ssl3_read_bytes:sslv3 alert certificate expired</Cause>
<MIBName>ipcsTlsHandshakeFailure</MIBName>
<Timestamp>1594933477674</Timestamp>
<IncidenceId>797466738837365</IncidenceId>
<Source>source-server</Source>
</StandardInfo>
</Incident>

尝试使用 xpath 获取 RemoteLocalTuple 数据,如下所示。

select xpath('/mydefns:Incident/mydefns:ExtraInformation/mydefbs:RemoteLocalTuple', xml_data) from incidents_data where mib_name='ipcsTlsHandshakeFailure';

select xpath('//Incidents/ExtraInformation/RemoteLocalTuple/text()',xml_data) from incidents_data where mib_name='ipcsTlsHandshakeFailure';

我在 xpath 命令上遇到错误。

错误:函数 xpath(未知,字符变化)不存在
提示:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。

服务器正在运行 psql (PostgreSQL) 9.4.21,并且在服务器上安装了 libxml2 库。

我是否以错误的方式使用 xpath 函数?

标签: postgresqlxpath

解决方案


推荐阅读