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.

Était-ce utile?

La 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(., '@')]]

Autres conseils

Should be as easy as:

//a[@*[contains(., 'domain')]][@*[contains(., '@')]]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top