如何在MySQL select中使用XPATH? [英] How to use XPATH in MySQL select?

查看:99
本文介绍了如何在MySQL select中使用XPATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个名为"xml"的表,该表将XML文件存储在单列数据"中.如何编写运行XPath并仅返回与该XPath匹配的行的MySQL查询?

Say I have a table called "xml" that stores XML files in a single column "data". How would I write a MySQL query that run an XPath and return only rows matching that XPath?

推荐答案

SELECT * FROM xml
WHERE EXTRACTVALUE(data, '<xpath-expr>') != '';

但是,您应该注意,MySQL对XPath的支持存在局限性.

You should note, however, that there are limitations to MySQL's support of XPath.

  • EXTRACTVALUE()仅返回CDATA.
  • 并非所有XPath构造都受支持.文档页面在abatishchev的答案中提到.
  • EXTRACTVALUE() returns only CDATA.
  • Not all XPath constructions are supported. Details under the heading "XPath limitations" on the doc page mentioned in abatishchev's answer.

这篇关于如何在MySQL select中使用XPATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆