\

Facebook


แสดงบทความที่มีป้ายกำกับ Simple HTML DOM Parser แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Simple HTML DOM Parser แสดงบทความทั้งหมด

วันจันทร์ที่ 23 กุมภาพันธ์ พ.ศ. 2558

PHP Simple HTML DOM Parser API

รวบรวม API ของ Simple HTML DOM เอาไว้ครับ สำหรับ link เต็มๆของหน้าหลักอยู่ที่นี้ คลาสตัวนี้เมื่อโหลดลงมาใช้มีประโยชน์ที่แปลงมาร์คอัพประเภท html ให้เป็น object DOM ทำง่ายต่อการค้นหา node ที่ต้องการไปใช้ต่อ บลาๆๆ ขี้เกียจอธิบาย จริงๆก็รู้กันอยู่เเล้ว แต่อยากรวบรวม ฟังชั่นที่ใช้บ่อยๆ+จำเป็น เอาไว้กันลืมครับ


อันนี้ Method >> ที่ผมใช้บ่อยๆ childNodes() , parentNode() เป็นต้นครับ การลบ element ของ DOM ทำไม่ได้ ต้องเลี่ยงมาใช้ removeAttribute() แทน เช่นลบ link ใน <iframe> เป็นต้น


Method Mapping
array
$e->getAllAttributes ()
array
$e->attr
string
$e->getAttribute ( $name )
string
$e->attribute
void
$e->setAttribute ( $name, $value )
void
$value = $e->attribute
bool
$e->hasAttribute ( $name )
bool
isset($e->attribute)
void
$e->removeAttribute ( $name )
void
$e->attribute = null
element
$e->getElementById ( $id )
mixed
$e->find ( "#$id", 0 )
mixed
$e->getElementsById ( $id [,$index] )
mixed
$e->find ( "#$id" [, int $index] )
element
$e->getElementByTagName ($name )
mixed
$e->find ( $name, 0 )
mixed
$e->getElementsByTagName ( $name [, $index] )
mixed
$e->find ( $name [, int $index] )
element
$e->parentNode ()
element
$e->parent ()
mixed
$e->childNodes ( [$index] )
mixed
$e->children ( [int $index] )
element
$e->firstChild ()
element
$e->first_child ()
element
$e->lastChild ()
element
$e->last_child ()
element
$e->nextSibling ()
element
$e->next_sibling ()
element
$e->previousSibling ()
element
$e->prev_sibling ()

ส่วนอันนี้ เป็น element ท่องไว้เลย ยังไงก็ได้ใช้



May be like this posts