<td></td><td>foo</td>
I would like to return ['', 'foo']
but libxml's xpath //td/text()
returns just ['foo']
. How do I find the empty tag as ''
instead of (not matched)?
While @Tomalak is perfectly right, in XPath 2.0 one can use:
//td/string(.)
and this produces a sequence of strings -- each one containing the string value of a corresponding td
element.
So, in your case the result will be the desired one:
"", "foo"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With