首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

xmerl_xpath

模块

xmerl_xpath

模块摘要

木乃伊[医]XPath模块处理整个XPath 1.0规范。

描述

木乃伊[医]XPath模块处理整个XPath 1.0规范。XPath表达式通常出现在XML属性中,用于处理XML文档的部分。语法定义为xmerl_xpath_parse.yrl.核心职能定义为xmerl_xpath_pred.erl

调试XPath解析器的一些有用的shell命令

代码语言:javascript
复制
c(xmerl_xpath_scan).
yecc:yecc("xmerl_xpath_parse.yrl", "xmerl_xpath_parse", true, []).
c(xmerl_xpath_parse).

xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("position() > -1")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6 div 2")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 + 6 mod 2")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("-----6")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::node()")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("descendant-or-self::node()")).
xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::processing-instruction('foo')")).
 

数据类型

docEntity()= #xmlDocument {} | [ docNodes()] docNodes()= #xmlElement {} | #xmlAttribute {} | #xmlText {} | #xmlPI {} | #xmlComment {} | #xmlNsNode {} nodeEntity()= #xmlElement {} | #xmlAttribute {} | #xmlText {} | #xmlPI {} | #xmlComment {} | #xmlNsNode {} | #xmlDocument {} option_list()

选项允许自定义XPath扫描器的行为。

可能的备选办法是:

{namespace, #xmlNamespace}

在xmlContext中设置XmlNamspace中的命名空间节点

{namespace, Nodes}

在xmlContext中设置命名空间节点。

parentList()= {atom(),integer()} xPathString()= string()

出口

string(Str, Doc) -> [docEntity()] | Scalar

相当于string(Str, Doc, [])

string(Str, Doc, Options) -> [docEntity()] | Scalar

相当于string(Str, Doc, [], Doc, Options)

string(Str, Node, Parents, Doc, Options) -> [docEntity()] | Scalar

类型

根据XPath从解析的XML树中提取节点。xmlObj是一个包含字段类型和值的记录,其中类型是布尔数字字符串。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com