Fix XPath parser
This commit is contained in:
parent
d95381f8fb
commit
a5346a47dc
@ -558,20 +558,16 @@ class XMLStream
|
|||||||
*/
|
*/
|
||||||
public function addXPathHandler(string $xpath, string $pointer, ?string $obj = null): void
|
public function addXPathHandler(string $xpath, string $pointer, ?string $obj = null): void
|
||||||
{
|
{
|
||||||
if (preg_match_all("/\(?{[^\}]+}\)?(\/?)[^\/]+/", $xpath, $regs)) {
|
if (preg_match_all('/\/?(\{[^\}]+\})?[^\/]+/', $xpath, $regs)) {
|
||||||
$ns_tags = $regs[0];
|
$tag = $regs[0];
|
||||||
} else {
|
} else {
|
||||||
$ns_tags = [$xpath];
|
$tag = [$xpath];
|
||||||
}
|
}
|
||||||
$xpath_array = [];
|
$xpath_array = [];
|
||||||
foreach ($ns_tags as $ns_tag) {
|
foreach ($tag as $t) {
|
||||||
list($l, $r) = explode("}", $ns_tag);
|
$t = ltrim($t, '/');
|
||||||
if ($r != null) {
|
preg_match('/(\{([^\}]+)\})?(.*)/', $t, $regs);
|
||||||
$xpart = [substr($l, 1), $r];
|
$xpath_array[] = [$regs[2], $regs[3]];
|
||||||
} else {
|
|
||||||
$xpart = [null, $l];
|
|
||||||
}
|
|
||||||
$xpath_array[] = $xpart;
|
|
||||||
}
|
}
|
||||||
$this->xpathhandlers[] = [$xpath_array, $pointer, $obj];
|
$this->xpathhandlers[] = [$xpath_array, $pointer, $obj];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user