Exemplo n.º 1
0
 /**
  * Convert DOMDocument in stdClass
  * @param \DOMDocument $dom
  * @param string $tag
  * @return \stdClass
  */
 protected function xml2Obj(DOMDocument $dom, $tag)
 {
     $node = $dom->getElementsByTagName($tag)->item(0);
     $newdoc = new DOMDocument('1.0', 'utf-8');
     $newdoc->appendChild($newdoc->importNode($node, true));
     $xml = $newdoc->saveXML();
     unset($newdoc);
     $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml);
     $xml = str_replace('<?xml version="1.0" encoding="utf-8"?>', '', $xml);
     $xml = str_replace('&lt;?xml version="1.0" encoding="UTF-8"?&gt;', '', $xml);
     $xml = str_replace('&lt;?xml version="1.0" encoding="utf-8"?&gt;', '', $xml);
     $xml = EntitiesCharacters::convert(html_entity_decode($xml));
     $resp = simplexml_load_string($xml, null, LIBXML_NOCDATA);
     $std = json_encode($resp);
     $std = str_replace('@attributes', 'attributes', $std);
     $std = json_decode($std);
     return $std;
 }
Exemplo n.º 2
0
 /**
  * Convert string xml message to cdata string
  * @param string $message
  * @return string
  */
 protected function stringTransform($message)
 {
     return EntitiesCharacters::unconvert(htmlentities($message, ENT_NOQUOTES));
 }