Question

I'm using XPath to parse an HTML document to find a specific link. The specific link has a domain name in it and the character '@'.

//a[@*[contains(., 'domain')]] | //a[@*[contains(., '@')]]"

Will return links with 'domain' OR '@' in them and I need 'domain' AND '@'

I've been trying to use:

//a[@*[contains(., 'domain')]] & //a[@*[contains(., '@')]]"

But that's no good.

Was it helpful?

Solution

You can read about XPath operators here. The & operator does not exist. Also, there is no need to select the element twice. You could use either

//a[@*[contains(., 'domain')]][@*[contains(., '@')]]

or

//a[@*[contains(., 'domain')] and @*[contains(., '@')]]

OTHER TIPS

Should be as easy as:

//a[@*[contains(., 'domain')]][@*[contains(., '@')]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top