本文整理汇总了PHP中Xml::createDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::createDocument方法的具体用法?PHP Xml::createDocument怎么用?PHP Xml::createDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::createDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
static function parse($str)
{
Xml::$build = Xml::createDocument();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, isset(Xml::$__start_element_handler) ? Xml::$__start_element_handler : array("Xml", "__start_element_handler"), isset(Xml::$__end_element_handler) ? Xml::$__end_element_handler : array("Xml", "__end_element_handler"));
xml_set_character_data_handler($xml_parser, isset(Xml::$__character_data_handler) ? Xml::$__character_data_handler : array("Xml", "__character_data_handler"));
xml_set_default_handler($xml_parser, isset(Xml::$__default_handler) ? Xml::$__default_handler : array("Xml", "__default_handler"));
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 0);
$isComplete = Xml::$xmlChecker->match($str);
if (!$isComplete) {
$str = "<doc>" . $str . "</doc>";
}
if (1 !== xml_parse($xml_parser, $str, true)) {
throw new HException("Xml parse error (" . (xml_error_string(xml_get_error_code($xml_parser)) . ") line #" . xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
if ($isComplete) {
return Xml::$build;
} else {
Xml::$build = Xml::$build->_children[0];
Xml::$build->_parent = null;
Xml::$build->_nodeName = null;
Xml::$build->nodeType = Xml::$Document;
return Xml::$build;
}
}
示例2: parse
static function parse($str)
{
Xml::$build = Xml::createDocument();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, isset(Xml::$__start_element_handler) ? Xml::$__start_element_handler : array("Xml", "__start_element_handler"), isset(Xml::$__end_element_handler) ? Xml::$__end_element_handler : array("Xml", "__end_element_handler"));
xml_set_character_data_handler($xml_parser, isset(Xml::$__character_data_handler) ? Xml::$__character_data_handler : array("Xml", "__character_data_handler"));
xml_set_default_handler($xml_parser, isset(Xml::$__default_handler) ? Xml::$__default_handler : array("Xml", "__default_handler"));
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 0);
Xml::$reHeader->match($str);
$str = "<doc>" . Xml::$reHeader->matchedRight() . "</doc>";
if (1 !== xml_parse($xml_parser, $str, true)) {
throw new HException("Xml parse error (" . (xml_error_string(xml_get_error_code($xml_parser)) . ") line #" . xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
Xml::$build = Xml::$build->_children[0];
Xml::$build->_parent = null;
Xml::$build->_nodeName = null;
Xml::$build->nodeType = Xml::$Document;
$doctype = Xml::$reHeader->matched(2);
if (null !== $doctype) {
Xml::$build->insertChild(Xml::createDocType($doctype), 0);
}
$prolog = Xml::$reHeader->matched(1);
if (null !== $prolog) {
Xml::$build->insertChild(Xml::createProlog($prolog), 0);
}
return Xml::$build;
}