P
P
Pavel Kornilov2020-02-04 12:45:36
PHP
Pavel Kornilov, 2020-02-04 12:45:36

How to get from DOM all nodes with attr attribute starting with 'begin...'?

Hello!
SUBJECT.

You need to get, using xPath, from the DOM all nodes with the clName class and the attr attribute starting with 'begin...'

<tag class="clName" attr="begin1">...</tag>
<tag class="clName" attr="begin2">...</tag>
<tag class="clName" attr="begin3">...</tag>


More specifically

From the page https://zen.yandex.ru/ (with disabled JS, of course) I'm trying to get all links with the specified parameters.

//a[@class='card-image-view__clickable' and starts-with(@href, 'https://zen.yandex.ru')]


Filter Inspector
a.card-image-view__clickable[href^='https://zen.yandex.ru']
finds 5 of them.


My attempt:
//tag[@class='clName']/@attr[starts-with(name(.), 'begin')]

But it doesn't work...

UPD
//tag[@class='clName' and starts-with(@attr, 'begin')]

Returns an empty NodeList.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Fov, 2020-02-04
@KorniloFF

//tag[@class='clName' and starts-with(@attr, 'begin')]

???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question