Xpath selects only part of the attribute

if

/dt/@id 

returns comment_34232 or comment_12 , how can I make it return 34232 or 12 (in other words, replacing 'comment_' with ''

and if

 /span/style 

returns width: 80%; how can I replace width: and after that %; get 80

Hello

+4
source share
1 answer

I. Part

if

 /dt/@id returns `comment_34232` or `comment_12` how can I make it return 

34232 or 12 (in other words, replacing 'comment_' with ''

Using

 substring-after(/dt/@id, '_') 

II. Part

and if

 /span/style returns `width: 80%;` how can I replace `width: ` and after 

to %; extract 80

Using

 substring-before(substring-after(/span/style, ' '), '%') 

Note : using the standard XPath functions substring-before() and substring-after() .

+4
source

Source: https://habr.com/ru/post/1335932/


All Articles