<text> tag in xpath inside <g> tag. How to create a xpath?

Hello!

Please advise how to reach the ‘text’ tag element?

the parent xpath:
//*[name()="g" and @id='MACHINE-ID']

Thank you!

The 1st <text> under the <g> could be selected by:

//*[name()="g" and @id='MACHINE-ID']/text[position()=1]

If you want to select a <text> that dislays “S-1274A”, then you want

//*[name()="g" and @id='MACHINE-ID']/text[contains(text(), 'S-1274A')]

no, it does not work with this ‘text’ tag.
I tried both of your suggestions.

Ah, Scalable Vector Graphics embeded in HTML!

Then you need to write far complex XPath.

For example

//*[local-name()='svg']//*[local-name()='g' and @id='MACHINE-ID']/*[local-name()='text' and position()=1]

For more info, Please have a look at the following post:

1 Like

Super! It works!

Thank you very very much!