Example #1
0
/**
 * Select elements from $html using the css $selector.
 * When $as_array is true elements and their children will
 * be converted to array's containing the following keys (defaults to true):
 *
 *  - name : element name
 *  - text : element text
 *  - children : array of children elements
 *  - attributes : attributes array
 *
 * Otherwise regular DOMElement's will be returned.
 */
function select_elements($selector, $html, $as_array = true)
{
    $dom = new SelectorDOM($html);
    return $dom->select($selector, $as_array);
}
Example #2
0
 /**
  * 指定されたセレクタの内容を配列で返す
  */
 private function getFileContent($html, $selectors)
 {
     $arr = array();
     $dom = new SelectorDOM($html);
     foreach ($selectors as $selector) {
         $t = $dom->select(str_replace('@', '', $selector));
         $arr[$selector] = sizeof($t) ? $t[0]['text'] : '';
     }
     return $arr;
 }