dcai
dcai

Reputation: 2555

Use xpath (libxml2) in Objective-C

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 detecting 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

Upvotes: 1

Views: 1029

Answers (1)

Michael-O
Michael-O

Reputation: 18430

Use this //div/h1/a/descendant-or-self::*/text().

Upvotes: 2

Related Questions