35 $this->_dom = new \DOMDocument();
47 $this->errorHandlerIsActive =
true;
72 $this->_currentDom = $node;
94 $currentNode = $this->
getDom();
97 foreach ($currentNode->childNodes as $node) {
98 switch ($node->nodeType) {
99 case XML_ELEMENT_NODE:
103 if ($node->hasChildNodes()) {
107 if ($node->hasAttributes()) {
113 if (isset(
$content[$node->nodeName])) {
114 if ((is_string(
$content[$node->nodeName]) || !isset(
$content[$node->nodeName][0]))
117 $oldValue =
$content[$node->nodeName];
119 $content[$node->nodeName][] = $oldValue;
126 case XML_CDATA_SECTION_NODE:
130 if (trim($node->nodeValue) !==
'') {
145 $this->
getDom()->load($file);
156 if ($this->errorHandlerIsActive) {
157 set_error_handler([$this,
'errorHandler']);
161 $this->
getDom()->loadXML($string);
162 }
catch (\
Magento\Framework\Exception\LocalizedException $e) {
163 restore_error_handler();
164 throw new \Magento\Framework\Exception\LocalizedException(
170 if ($this->errorHandlerIsActive) {
171 restore_error_handler();
187 public function errorHandler($errorNo, $errorStr, $errorFile, $errorLine)
190 $message =
"{$errorStr} in {$errorFile} on line {$errorLine}";
_xmlToArray($currentNode=false)
errorHandler($errorNo, $errorStr, $errorFile, $errorLine)