xpath remove an attribute from an dynamic attribute list -


i want remove xml attribute via xpath, xml element have more atrributes in future.

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> 

is better way fixtext "red, blue"?

in order suppport possible new version of html file "<p class="red, blue, green, brown">test</p>" in future without need change xpath code again.

for instance actual attribute list var + xpath function

what setting @class to

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

you'll need solve abandoned commas, too, björn tantau commented, in real html classes separated spaces, can wrap result normalize-space.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -