| @@ 12-41 (lines=30) @@ | ||
| 9 | * @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved. |
|
| 10 | * @license LICENSE MIT |
|
| 11 | */ |
|
| 12 | class XMLReader extends OriginalXMLReader |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * This is a blend of XMLReader's read & next, in that it accepts a node |
|
| 16 | * name to search for, but it doesn't assume the node if on the same level |
|
| 17 | * in DOM hierarchy as where you're currently at: it won't skip children & |
|
| 18 | * it will cross parents (unless. |
|
| 19 | * |
|
| 20 | * @param string $name Name of the node we're looking for. |
|
| 21 | * @param string $parent Name of parent node(s) to stay inside of. |
|
| 22 | * |
|
| 23 | * @return bool |
|
| 24 | */ |
|
| 25 | public function readNext($name, $parent = null) |
|
| 26 | { |
|
| 27 | while ($this->read()) { |
|
| 28 | // next node |
|
| 29 | if ($this->localName === $name && $this->nodeType === self::ELEMENT) { |
|
| 30 | return true; |
|
| 31 | } |
|
| 32 | ||
| 33 | // stop processing at and of this node |
|
| 34 | if ($this->localName === $parent && $this->nodeType === self::END_ELEMENT) { |
|
| 35 | return false; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| 39 | return false; |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 12-41 (lines=30) @@ | ||
| 9 | * @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved. |
|
| 10 | * @license LICENSE MIT |
|
| 11 | */ |
|
| 12 | class XMLReader extends OriginalXMLReader |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * This is a blend of XMLReader's read & next, in that it accepts a node |
|
| 16 | * name to search for, but it doesn't assume the node if on the same level |
|
| 17 | * in DOM hierarchy as where you're currently at: it won't skip children & |
|
| 18 | * it will cross parents (unless. |
|
| 19 | * |
|
| 20 | * @param string $name Name of the node we're looking for. |
|
| 21 | * @param string $parent Name of parent node(s) to stay inside of. |
|
| 22 | * |
|
| 23 | * @return bool |
|
| 24 | */ |
|
| 25 | public function readNext($name, $parent = null) |
|
| 26 | { |
|
| 27 | while ($this->read()) { |
|
| 28 | // next node |
|
| 29 | if ($this->localName === $name && $this->nodeType === self::ELEMENT) { |
|
| 30 | return true; |
|
| 31 | } |
|
| 32 | ||
| 33 | // stop processing at and of this node |
|
| 34 | if ($this->localName === $parent && $this->nodeType === self::END_ELEMENT) { |
|
| 35 | return false; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| 39 | return false; |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||