mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-19 03:09:55 +09:00
XmlParser class로 뺌
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3305 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
548c58b30a
commit
190a67301e
2 changed files with 9 additions and 3 deletions
|
|
@ -8,7 +8,7 @@
|
|||
set_include_path("./modules/springnote/lib/PEAR");
|
||||
require_once('PEAR.php');
|
||||
require_once('HTTP/Request.php');
|
||||
require_once('me2dayXmlParser.class.php');
|
||||
require_once('./classes/xml/GeneralXmlParser.class.php');
|
||||
|
||||
class lifepodModel extends lifepod {
|
||||
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
$body = $oReqeust->getResponseBody();
|
||||
|
||||
$oXmlParser = new Me2DayXmlParser();
|
||||
$oXmlParser = new GeneralXmlParser();
|
||||
$xmldoc = $oXmlParser->parse($body);
|
||||
if(!$xmldoc->childNodes["feed"]->childNodes["entry"])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
class Me2DayXmlParser {
|
||||
var $output = array();
|
||||
|
||||
function parse($input = '') {
|
||||
$oParser = xml_parser_create('UTF-8');
|
||||
xml_set_object($oParser, $this);
|
||||
xml_set_element_handler($oParser, "_tagOpen", "_tagClosed");
|
||||
xml_set_character_data_handler($oParser, "_tagBody");
|
||||
|
||||
xml_parse($oParser, $input);
|
||||
xml_parser_free($oParser);
|
||||
|
||||
if(!count($this->output)) return;
|
||||
$this->output = array_shift($this->output);
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 태그 오픈
|
||||
**/
|
||||
function _tagOpen($parser, $node_name, $attrs) {
|
||||
$obj->node_name = strtolower($node_name);
|
||||
$obj->attrs = $attrs;
|
||||
$obj->childNodes = array();
|
||||
|
||||
array_push($this->output, $obj);
|
||||
}
|
||||
|
||||
function _tagBody($parser, $body) {
|
||||
//if(!trim($body)) return;
|
||||
$this->output[count($this->output)-1]->body .= $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 태그 닫음
|
||||
**/
|
||||
function _tagClosed($parser, $node_name) {
|
||||
$node_name = strtolower($node_name);
|
||||
$cur_obj = array_pop($this->output);
|
||||
$parent_obj = &$this->output[count($this->output)-1];
|
||||
|
||||
if($parent_obj->childNodes[$node_name]) {
|
||||
$tmp_obj = $parent_obj->childNodes[$node_name];
|
||||
if(is_array($tmp_obj)) {
|
||||
array_push($parent_obj->childNodes[$node_name], $cur_obj);
|
||||
} else {
|
||||
$parent_obj->childNodes[$node_name] = array();
|
||||
array_push($parent_obj->childNodes[$node_name], $tmp_obj);
|
||||
array_push($parent_obj->childNodes[$node_name], $cur_obj);
|
||||
}
|
||||
} else {
|
||||
$parent_obj->childNodes[$node_name] = $cur_obj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue