普贤教程 › 包参考
xpath 包
XPath 简化查询(基于 domlite)
xpath.px — XPath 简化查询(基于 domlite)
| 项 | 值 |
|---|---|
| 包名 | xpath |
| 版本 | 0.1.0 |
| 入口 | xpath.px |
| 分类 | 数据格式与编解码 |
| 文件数 / 行数 | 2 / 110 |
安装与引入
bash
pxpkg init # 首次 pxpkg add xpath@0.1.0 pxpkg install
px
import xpath所属分类教程:数据格式与编解码
其余 18 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
dom_new | tag, attrs, children |
dom_text | text |
dom_append | parent, child |
dom_set_attr | node, key, val |
dom_get_attr | node, key |
dom_get_children | node |
dom_find_by_tag | node, tag |
dom_to_xml | node, indent |
dom_inner_text | node |
dom_count | node |
xp_select_all | node, tag |
xp_select_first | node, tag |
xp_select_by_attr | node, tag, attr_name, attr_val |
xp_count | node, tag |
xp_text | node, tag |
xp_attr | node, tag, attr_name |
xp_exists | node, tag |
xp_select_children | node, tag |
包内说明(源码头注释)
text
xpath.px — XPath 简化查询(基于 domlite)
⇒ 安装到 .px_modules/<pkg>/ 后不存在 ⇒ 严格模块模式 E3005(装包后加载失败)。
改为**同包相对 import**(pxpkg 明确支持、安装后不变):把 domlite 副本随包分发。