开发者

parsing html data iphone xpath

开发者 https://www.devze.com 2023-03-28 22:41 出处:网络
have this webpage http://www.westminster.ac.uk/schools/computing/undergraduate . I\'m using hpple to retrieve data (just started learning about it). I want to specifically retrieve the href from he ma

have this webpage http://www.westminster.ac.uk/schools/computing/undergraduate . I'm using hpple to retrieve data (just started learning about it). I want to specifically retrieve the href from he main page, how can i do t开发者_高级运维his?

I have this line - "NSArray *elements = [xpathParser search:@"//a"];" is able to retrieve all of the href links within the page however how can i retrieve just the ones in the main content? e.g. "BSc Honors Busniess Information Systems"? whats the syntax for it?


It looks like all of the "main content" stuff is found underneath elements with id attributes like "content_div_XXXX" where XXXX is some randomly generated sequence. You might be able to get at what you want using an XPath that looks something like:

//div[starts-with(@id,'content_div')]//a

You should be able to get something like this working, although you'd have to try it out and perhaps tweak it a bit to make it work precisely as you want. Refer to W3Schools XPath page for a good set of XPath tutorials

0

精彩评论

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