Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
XML XPath筛选器Wordpress WPALLIMPORT_Xml_Wordpress_Xpath - Fatal编程技术网

XML XPath筛选器Wordpress WPALLIMPORT

XML XPath筛选器Wordpress WPALLIMPORT,xml,wordpress,xpath,Xml,Wordpress,Xpath,我想从XML导入产品(类别) 类别元素为RCA,其中“RCA”为类别 我想要多个类别 对于单个类别,我使用了“/product[contains(type,“RCA”)]”“,尽管它可以工作,但它给了我所有带有单词“RCA”的类别 还有,如何过滤多个类别?例如,当我这样做时: “/产品[包含(类型,“RCA”或类型,“卡侬”或“DVI”或“HDMI”)” …它不起作用。据我所知,您可能希望使用以下内容: /product[contains(type, "RCA") or co

我想从XML导入产品(类别)

类别元素为RCA,其中“RCA”为类别

我想要多个类别

对于单个类别,我使用了
“/product[contains(type,“RCA”)]”“
,尽管它可以工作,但它给了我所有带有单词“RCA”的类别

还有,如何过滤多个类别?例如,当我这样做时:

“/产品[包含(类型,“RCA”或类型,“卡侬”或“DVI”或“HDMI”)”

…它不起作用。

据我所知,您可能希望使用以下内容:

/product[contains(type, "RCA") or contains(type, "someOtherType")]
未经测试,但值得一试。

试试这个:

/product[type[contains('RCAXLRDVIHDMI',.)]]
这是另一种方式

/product
(单斜杠)可能有问题。这通常只会选择根元素。如果您只想要child::product,请使用它而不使用任何斜杠
产品
产品
。如果希望所有子体都使用
//product
子体::product

如果您有更多的类别,XPath会更安全,因为它周围的空格只匹配这些类型,而不匹配彼此内部的类型,比如一和一

/product[type[contains(' RCA XLR DVI HDMI ',concat(' ',.,' '))]]

请分享一个xml示例