开发者

Use xpath (libxml2) in Objective-C

开发者 https://www.devze.com 2023-03-26 03:20 出处:网络
I learned the libxml2 from http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html Trying to parsing following html using libxml2:

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消