Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xpath选择函数?_Xpath - Fatal编程技术网

Xpath选择函数?

Xpath选择函数?,xpath,Xpath,我正在使用Drupal7CMS中的提要导入模块,该模块接受xpath指令来映射导入数据。是否可以只选择原子值的一部分或使用xpath分解它? 例如: <book> ... <categories>1,4,88</categories> ... </book> ... 1,4,88 ... 使用xpath语句只能分别得到1、4或88吗?您可以使用and函数: 要选择1:子字符串(/book/categories,,'), 要选择4:befo

我正在使用Drupal7CMS中的提要导入模块,该模块接受xpath指令来映射导入数据。是否可以只选择原子值的一部分或使用xpath分解它? 例如:

<book>
...
<categories>1,4,88</categories>
...
</book> 

...
1,4,88
...
使用xpath语句只能分别得到1、4或88吗?

您可以使用and函数:

  • 要选择1:
    子字符串(/book/categories,,'),
  • 要选择4:
    before子字符串(before子字符串后(/book/categories,,),,,)
  • 要选择88:
    substring after(substring after(/book/categories,,),,,)

使用XPath 2.0,您可以使用以下函数:

  • 要选择1:
    tokenize(/book/categories,,)[1]
  • 选择4:
    tokenize(/book/categories,,)[2]
  • 要选择88:
    tokenize(/book/categories,,)[3]

或者,使用XPath 2.0,可以通过以下方式访问
N
th组件:

tokenize(/*/categories[1], ',')[$pN]
其中,
$pN
是所需的基于1的索引