1

I want to parse html to get tag attribute, but I want to change the value of that attribute using substring function. I'm using libxml2.2.tdb framework with TFHpple addon

HTML to parse:

<div>
  <img src="00-abc.jpg">
</div>

What I want to get:

abc.jpg

What I tried (and it didn't work):

substring(//div/img/@src, 3)
replace(//div/img/@src, "00-")
//div/img/@src[substring(., 3)]
  • The expression `substring(//div/img/@src, 3)` should work, but note that XPath string indices are 1-based, so it should be `substring(//div/img/@src, 4)`. But I guess you would have figured that out, so it seems that something else is going on. It's hard to tell without further details. You should post the full code that evaluates the XPath expression, preferably as an [MCVE](http://stackoverflow.com/help/mcve). – nwellnhof Sep 19 '16 at 12:55

0 Answers0