From 621ae09adec8e6e9ac090166098f22f30b97b1d6 Mon Sep 17 00:00:00 2001 From: arnaudBelin Date: Thu, 25 Apr 2024 13:55:52 +0200 Subject: [PATCH] Remove ns4 prefix --- lib/PayPal/Core/PPUtils.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/PayPal/Core/PPUtils.php b/lib/PayPal/Core/PPUtils.php index ab883dd..8188bc2 100644 --- a/lib/PayPal/Core/PPUtils.php +++ b/lib/PayPal/Core/PPUtils.php @@ -120,8 +120,14 @@ private static function xmlNodeToArray($node) for ($i = 0; $i < (int)$children->length; $i++) { $child = $children->item($i); if ($child !== null) { + $nodeName = $child->nodeName; + if (strpos($nodeName, 'ns4:') === 0) { + // Remove the 'ns4:' prefix + $nodeName = substr($nodeName, 4); + } + if ($child->childNodes->item(0) instanceof \DOMText) { - $result[$i]['name'] = $child->nodeName; + $result[$i]['name'] = $nodeName; $result[$i]['text'] = $child->childNodes->item(0)->nodeValue; if ($child->hasAttributes()) { foreach ($child->attributes as $k => $v) { @@ -130,8 +136,8 @@ private static function xmlNodeToArray($node) } } } - } else if (!in_array($child->nodeName, $result)) { - $result[$i]['name'] = $child->nodeName; + } else if (!in_array($nodeName, $result)) { + $result[$i]['name'] = $nodeName; $result[$i]['children'] = PPUtils::xmlNodeToArray($child); if ($child->hasAttributes()) {