How do I return '' for an empty node's text() in XPath?

Posted by joeforker on Stack Overflow See other posts from Stack Overflow or by joeforker
Published on 2010-03-10T21:23:15Z Indexed on 2010/03/11 19:24 UTC
Read the original article Hit count: 103

Filed under:
|

<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)?

© Stack Overflow or respective owner

Related posts about xpath

Related posts about libxml2