/**
  * Default handler for all other XML sections not implemented as callback
  * @param resource $parser a resource handle of the XML parser
  * @param mixed $data
  * @throws XmlToArrayException
  */
 private function _default($parser, $data)
 {
     $data = trim($data);
     if (in_array($data, get_html_translation_table(HTML_ENTITIES))) {
         $this->_CurrentXmlToArrayNode instanceof XmlToArrayNode && $this->_CurrentXmlToArrayNode->setData(html_entity_decode($data));
     } elseif ($data && isset(self::$_htmlEntityExceptions[$data])) {
         $this->_CurrentXmlToArrayNode instanceof XmlToArrayNode && $this->_CurrentXmlToArrayNode->setData(self::$_htmlEntityExceptions[$data]);
     } elseif ($data && is_string($data) && strpos($data, '<!--') === false) {
         trigger_error('Default data handler used. The data passed was: ' . $data, E_USER_WARNING);
         throw new XmlToArrayException('Unknown error occurred');
     }
 }
Exemplo n.º 2
0
 public function testSetData()
 {
     $XmlToArrayNode = new XmlToArrayNode($this->_name, $this->_attributes);
     $data = 'test';
     $XmlToArrayNode->setData($data);
     $this->assertEquals($data, $XmlToArrayNode->getData());
     $data2 = 'MoreData';
     $XmlToArrayNode->setData($data2);
     $this->assertEquals($data . $data2, $XmlToArrayNode->getData());
 }