Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.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,我想通过xpath删除xml属性,但是 xml元素将来可能会有更多的属性 html code: <p class="red, blue, green">test/<p> xpath: <xpath expr="//p[contains(@class, 'green')]" position="attributes"> <attribute name="class">red, blue</attribute

我想通过xpath删除xml属性,但是 xml元素将来可能会有更多的属性

html code:
    <p class="red, blue, green">test/<p>

xpath: 
    <xpath expr="//p[contains(@class, 'green')]" position="attributes">
         <attribute name="class">red, blue</attribute>
    </xpath>
html代码:

测试 xpath: 红色,蓝色

哪里是修复文本“红色,蓝色”的更好方法

为了支持html文件的新版本,如

将来测试”

,无需再次更改xpath代码


例如,实际属性列表为var+xpath函数

将@class设置为

concat(substring-before(@class, "green"), substring-after(@class, "green"))

您还需要解决被放弃的逗号,但正如Björn Tantau所评论的,在真实的HTML中,类将由空格分隔,因此您可以将结果包装到
规范化空格中

将@class设置为

concat(substring-before(@class, "green"), substring-after(@class, "green"))

你也需要解决被抛弃的逗号,但正如Björn Tantau评论的那样,在真正的HTML中,类将由空格分隔,因此你可以将结果包装成
规范化空格

只是一个旁白,通常HTML中的类不是由逗号分隔的,而是由空格分隔的。只是一个旁白,通常html中的类不是用逗号分隔的,而是用空格分隔的。谢谢红,蓝,绿是一个拼写错误,我的意思是“红,蓝,绿”谢谢红,蓝,绿是一个拼写错误,我的意思是“红,蓝,绿”