S
S
Shimpanze2019-07-23 04:57:16
PHP
Shimpanze, 2019-07-23 04:57:16

How to get the pure value of an attribute in XPath?

Hello!
Expression:
"//a/@href"
Outputs: And how to get a pure value ? This: I dug up the entire Internet, I didn’t find anything sensible (except how to use regular expressions).
href="site.com/3572"
href
site.com/3572

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2019-07-23
@Shimpanze

you have a very strange internet. Yes, and you need to dig not it, but the xpath dock in general and xpath in puff in particular.

foreach ($xpath->query('//a/@href') as $href) {
  echo $href->nodeValue, PHP_EOL;
}
https://3v4l.org/0XlvA

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question