Answer the question
In order to leave comments, you need to log in
How to get text outside of tag using xpath?
Hello. I have this html snippet
<article class="eText">
<p class="">
<b class="">Год:</b> 2019-2020
<br class="">
<b class="">Жанр:</b> Приключения, фэнтези, мультсериал
<br class="">
<b class="">Перевод / Озвучивание:</b> Многоголосый дубляж от Wakanim
<br class="">
<b class="">Время:</b> 22 х ~ 00:24:00
<br class="">
<b class="">Произведено:</b> Япония, CloverWorks
<br class="">
<b class="">Режиссер:</b> Тосифуми Акай
<br class="">
<b class="">Актеры:</b> Нобунага Симадзаки, Риэ Такахаси, Аяко Кавасуми, Кэнъити Судзумура, Маая Сакамото, Томокадзу Сэки, Ю Кобаяси, Такахиро Сакурай, Ю Асакава, Кана Уэда
</p>
</article>
//article[@class='eText']/p/b[contains(.,'Жанр:')]
Answer the question
In order to leave comments, you need to log in
Is it possible to write a universal xpath query that will change the contents of contains to get these text values.
//article[@class='eText']/p/b[. = 'Жанр:']/following-sibling::text()[1]
<article class="eText">
<p class="">
<b class="">Жанр:</b>вфывафыва
<b class="">Время:</b> 22 х ~ 00:24:00
</p>
</article>
Text='вфывафыва'
//article[@class='eText']/p/b[text() = 'Жанр:'][generate-id(following-sibling::text()[1]/preceding-sibling::node()[1]) = generate-id(.)]/normalize-space(following-sibling::text()[1])
<article class="eText">
<p class="">
<b class="">Жанр:</b><b class="">Жанр:</b>Многоголосый дубляж от Wakanim
<b class="">Время:</b> 22 х ~ 00:24:00
</p>
</article>
String='Многоголосый дубляж от Wakanim'
<b>
. Not sure how descriptive illustrated) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question