| @@ 295-318 (lines=24) @@ | ||
| 292 | * |
|
| 293 | * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank |
|
| 294 | */ |
|
| 295 | public function getElementsByTagName($name, $idx = null) |
|
| 296 | { |
|
| 297 | $nodesList = $this->document->getElementsByTagName($name); |
|
| 298 | ||
| 299 | $elements = new SimpleHtmlDomNode(); |
|
| 300 | ||
| 301 | foreach ($nodesList as $node) { |
|
| 302 | $elements[] = new SimpleHtmlDom($node); |
|
| 303 | } |
|
| 304 | ||
| 305 | if (null === $idx) { |
|
| 306 | return $elements; |
|
| 307 | } else { |
|
| 308 | if ($idx < 0) { |
|
| 309 | $idx = count($elements) + $idx; |
|
| 310 | } |
|
| 311 | } |
|
| 312 | ||
| 313 | if (isset($elements[$idx])) { |
|
| 314 | return $elements[$idx]; |
|
| 315 | } else { |
|
| 316 | return new SimpleHtmlDomNodeBlank(); |
|
| 317 | } |
|
| 318 | } |
|
| 319 | ||
| 320 | /** |
|
| 321 | * Find list of nodes with a CSS selector. |
|
| @@ 296-319 (lines=24) @@ | ||
| 293 | * |
|
| 294 | * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank |
|
| 295 | */ |
|
| 296 | public function getElementsByTagName($name, $idx = null) |
|
| 297 | { |
|
| 298 | $nodesList = $this->node->getElementsByTagName($name); |
|
| 299 | ||
| 300 | $elements = new SimpleHtmlDomNode(); |
|
| 301 | ||
| 302 | foreach ($nodesList as $node) { |
|
| 303 | $elements[] = new SimpleHtmlDom($node); |
|
| 304 | } |
|
| 305 | ||
| 306 | if (null === $idx) { |
|
| 307 | return $elements; |
|
| 308 | } else { |
|
| 309 | if ($idx < 0) { |
|
| 310 | $idx = count($elements) + $idx; |
|
| 311 | } |
|
| 312 | } |
|
| 313 | ||
| 314 | if (isset($elements[$idx])) { |
|
| 315 | return $elements[$idx]; |
|
| 316 | } else { |
|
| 317 | return new SimpleHtmlDomNodeBlank(); |
|
| 318 | } |
|
| 319 | } |
|
| 320 | ||
| 321 | /** |
|
| 322 | * Create a new "HtmlDomParser"-object from the current context. |
|