I learned the libxml2 from http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html Trying to parsing following html using libxml2:
<html><head></head>
<body>
<div id="content">
<h1><a href="#">Content <em>1</em> <em>2</em></a></h1>
</div>
</body>
</html>
Is there a way to get all content in h1 without detect开发者_Go百科ing all child? if I use
//div/h1/a
I only get "Content"
If I use
//div/h1/a/descendant-or-self::*
I only got the content in
Is there a way to get "Content 1 2"?
Thanks
Use this //div/h1/a/descendant-or-self::*/text()
.
精彩评论