码迷,mamicode.com
首页 > Web开发 > 详细

simple_html_dom(3)

时间:2014-10-14 22:27:19      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   ar   for   strong   sp   div   on   

How to traverse the DOM tree?

// If you are not so familiar with HTML DOM, check this link to learn more... 

// Example
echo $html->find("#div1", 0)->children(1)->children(1)->children(2)->id;
// or 
echo $html->getElementById("div1")->childNodes(1)->childNodes(1)->childNodes(2)->getAttribute(‘id‘);

You can also call methods with Camel naming convertions.

MethodDescription
mixed
$e->children ( [int $index] )
Returns the Nth child object if index is set, otherwise return an array of children.
element
$e->parent ()
Returns the parent of element.
element
$e->first_child ()
Returns the first child of element, or null if not found.
element
$e->last_child ()
Returns the last child of element, or null if not found.
element
$e->next_sibling ()
Returns the next sibling of element, or null if not found.
element
$e->prev_sibling ()
Returns the previous sibling of element, or null if not found.

simple_html_dom(3)

标签:des   http   io   ar   for   strong   sp   div   on   

原文地址:http://www.cnblogs.com/goAhead-hust/p/4025035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!