سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

Should be as easy as:

//a[@*[contains(., 'domain')]][@*[contains(., '@')]]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top