function SAXY_Test() { $sp = new SAXY_Parser(); $sp->xml_set_element_handler(array(&$this, "startElement"), array(&$this, "endElement")); $sp->xml_set_character_data_handler(array(&$this, "charData")); $sp->parse("<book><title><![CDATA[How to use SAXY]]></title><author>John Heinstein</author></book>"); }
public function parse($quickMode = false) { $this->_resetValues(); $this->_quickParseMode = $quickMode; require_once IA_INCLUDES . 'xml' . IA_DS . 'xml_saxy_parser.php'; $xmlParser = new SAXY_Parser(); $xmlParser->xml_set_element_handler(array(&$this, '_parserStart'), array(&$this, '_parserEnd')); $xmlParser->xml_set_character_data_handler(array(&$this, $quickMode ? '_parserQuickData' : '_parserData')); $xmlParser->xml_set_comment_handler(array(&$this, '_parserComment')); $xmlParser->parse($this->_xmlContent); $this->_parsed = true; $this->_checkDependencies(); }
/** * Parses xml text using SAXY * @param Object A reference to the DOM document that the xml is to be parsed into * @param string The text to be parsed * @param boolean True if CDATA Section nodes are not to be converted into Text nodes * @return boolean True if the parsing is successful */ function parseSAXY(&$myXMLDoc, $xmlText, $preserveCDATA = true, $definedEntities) { require_once DOMIT_INCLUDE_PATH . 'xml_saxy_parser.php'; $this->xmlDoc =& $myXMLDoc; $this->lastChild =& $this->xmlDoc; //create instance of SAXY parser $parser = new SAXY_Parser(); $parser->appendEntityTranslationTable($definedEntities); //not yet implemented in SAXY!!! $parser->preserveWhitespace = $this->xmlDoc->preserveWhitespace; if ($this->xmlDoc->isNamespaceAware) { $parser->setNamespaceAwareness(true); $parser->xml_set_start_namespace_decl_handler(array(&$this, 'startNamespaceDeclaration')); $parser->xml_set_end_namespace_decl_handler(array(&$this, 'endNamespaceDeclaration')); $parser->xml_set_element_handler(array(&$this, 'startElementNS'), array(&$this, 'endElement')); $this->xmlDoc->namespaceURIMap[DOMIT_XML_NAMESPACE] = 'xml'; } else { $parser->xml_set_element_handler(array(&$this, 'startElement'), array(&$this, 'endElement')); } $parser->xml_set_character_data_handler(array(&$this, 'dataElement')); $parser->xml_set_doctype_handler(array(&$this, 'doctypeElement')); $parser->xml_set_comment_handler(array(&$this, 'commentElement')); $parser->xml_set_processing_instruction_handler(array(&$this, 'processingInstructionElement')); if ($preserveCDATA) { $parser->xml_set_cdata_section_handler(array(&$this, 'cdataElement')); } $success = $parser->parse($xmlText); $this->xmlDoc->errorCode = $parser->xml_get_error_code(); $this->xmlDoc->errorString = $parser->xml_error_string($this->xmlDoc->errorCode); return $success; }
public function parse() { require_once IA_INCLUDES . 'xml' . IA_DS . 'xml_saxy_parser' . iaSystem::EXECUTABLE_FILE_EXT; $xmlParser = new SAXY_Parser(); $xmlParser->xml_set_element_handler(array(&$this, 'startElement'), array(&$this, 'endElement')); $xmlParser->xml_set_character_data_handler(array(&$this, 'charData')); $this->_resetValues(); $xmlParser->parse($this->_xml); }