Jak używać "nie" w xpath?
Chcę napisać coś takiego:
//a[not contains(@id, 'xx')]
(co oznacza, że wszystkie linki, których atrybut 'id' nie zawiera ciągu znaków 'xx')
Nie mogę znaleźć odpowiedniej składni.
142
3 answers
Not() jest funkcją w xpath (w przeciwieństwie do operatora), więc
//a[not(contains(@id, 'xx'))]
206
Author: James Sulak,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-10-11 15:45:50
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-10-11 15:45:50
Możesz użyć not(expression)
funkcji
Lub
expression != true()
35
Author: Abdelhameed Mahmoud,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-05-17 12:16:03
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-05-17 12:16:03
Żadna z tych odpowiedzi nie zadziałała dla mnie w Pythonie. Rozwiązałem to
a[not(@id='XX')]
Możesz również użyć lub warunkować w swojej xpath przez |
operator. Takie jak
a[not(@id='XX')]|a[not(@class='YY')]
Czasami chcemy elementu, który nie ma klasy. Więc możesz zrobić jak
a[not(@class)]
7
Author: Harun ERGUL,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-17 14:59:42
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-17 14:59:42