开发者

hpple html parse block by block or property by property?

I'm new about hpple and xpath. for the below html code,I want to get both "title" and "tag" information.

From hpple's example code, I can get a array of title, and another array of tag. But if there are six properties I'm interested, there will be six arrays.

can I find the div[class="entry"], then get its child's , div[class="meta"]? (can anybody share the code?)

Thanks.

<div class="content">

<div id="1" class="entry">
  <h2 class="title"> title for  entry 1 </h2>
 <div class="meta"> tag:xxx </div>
</div>

<div id="2" class="entry">
  <h2 clas开发者_StackOverflows="title"> title for  entry 2 </h2>
 <div class="meta"> tag:xxx </div>
</div>

...

</div>


@"//div[@class='content']//div[@class='entry']//div[@class='meta']"

This returns tag:xxx for both entries.


I want to get both "title" and "tag" information

//div[@class='content']/div[@class='entry']/*[@class='meta' or @class=title"']

This XPath gets all tags with class title or meta children of div class entry child of any div class content.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜