本文整理汇总了PHP中XmlParser类的典型用法代码示例。如果您正苦于以下问题:PHP XmlParser类的具体用法?PHP XmlParser怎么用?PHP XmlParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testParseWithIntegerIndexedArray
public function testParseWithIntegerIndexedArray()
{
$testXml = simplexml_load_file('./tests/raw/test_feed.xml');
$parser = new XmlParser($testXml);
$results = $parser->parse();
$this->assertTrue(isset($results['rss']['channel']));
}
开发者ID:brianseitel,项目名称:ook,代码行数:7,代码来源:XMLParserTest.php
示例2: proc
/**
* @brief 위젯의 실행 부분
*
* ./widgets/위젯/conf/info.xml 에 선언한 extra_vars를 args로 받는다
* 결과를 만든후 print가 아니라 return 해주어야 한다
**/
function proc($args)
{
// 위젯 자체적으로 설정한 변수들을 체크
$title = $args->title;
$PAGE_LIMIT = $args->page_limit ? $args->page_limit : 10;
// 날짜 형태
$DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
$buff = $this->rss_request($args->rss_url);
if (!is_string($buff) or !$buff) {
return Context::getLang('msg_fail_to_request_open');
}
$encoding = preg_match("/<\\?xml.*encoding=\"(.+)\".*\\?>/i", $buff, $matches);
if ($encoding && !preg_match("/UTF-8/i", $matches[1])) {
$buff = trim(iconv($matches[1] == "ks_c_5601-1987" ? "EUC-KR" : $matches[1], "UTF-8", $buff));
}
$buff = preg_replace("/<\\?xml.*\\?>/i", "", $buff);
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($buff);
$rss->title = $xml_doc->rss->channel->title->body;
$rss->link = $xml_doc->rss->channel->link->body;
$items = $xml_doc->rss->channel->item;
if (!$items) {
return Context::getLang('msg_invalid_format');
}
if ($items && !is_array($items)) {
$items = array($items);
}
$rss_list = array();
foreach ($items as $key => $value) {
if ($key >= $PAGE_LIMIT) {
break;
}
unset($item);
foreach ($value as $key2 => $value2) {
if (is_array($value2)) {
$value2 = array_shift($value2);
}
$item->{$key2} = $value2->body;
}
$date = $item->pubdate;
$item->date = $date ? date($DATE_FORMAT, strtotime($date)) : '';
$array_date[$key] = strtotime($date);
$item->description = preg_replace('!<a href=!is', '<a onclick="window.open(this.href);return false" href=', $item->description);
$rss_list[$key] = $item;
}
array_multisort($array_date, SORT_DESC, $rss_list);
$widget_info->rss = $rss;
$widget_info->rss_list = $rss_list;
$widget_info->title = $title;
$widget_info->rss_height = $args->rss_height ? $args->rss_height : 200;
$widget_info->subject_cut_size = $args->subject_cut_size;
Context::set('widget_info', $widget_info);
// 템플릿의 스킨 경로를 지정 (skin, colorset에 따른 값을 설정)
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
Context::set('colorset', $args->colorset);
// 템플릿 컴파일
$oTemplate =& TemplateHandler::getInstance();
$output = $oTemplate->compile($tpl_path, 'list');
return $output;
}
开发者ID:hottaro,项目名称:xpressengine,代码行数:66,代码来源:rss_reader.class.php
示例3: send_order
/**
* Block Send XML order to Moulton
* @author Oleg D.
*/
function send_order()
{
$result = array();
$xml_order = $this->build_order_xml();
$xml_order = preg_replace("/(\\s+)?(\\<.+\\>)(\\s+)?/", "\$2", $xml_order);
$xml_order = str_replace('&', '&', $xml_order);
echo $xml_order;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_order);
if ($this->testing) {
curl_setopt($ch, CURLOPT_URL, $this->send_order_url_test);
} else {
curl_setopt($ch, CURLOPT_URL, $this->send_order_url);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
$moulton_answer = curl_exec($ch);
curl_close($ch);
include 'xmlparser.class.php';
$Parser = new XmlParser();
$result = $Parser->xml2array($moulton_answer);
return $result;
}
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:29,代码来源:class.MoultonAPI.php
示例4: init
function init()
{
// forbit access if the user is not an administrator
if (!$this->grant->manager && !$this->grant->is_admin) {
return $this->stop("msg_is_not_administrator");
}
// change into administration layout
//$this->setTemplatePath('./modules/cympusadmin/tpl');
$this->setLayoutPath('./modules/cympusadmin/tpl');
$this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/');
if ($this->grant->is_admin) {
// parse admin menu
$oXmlParser = new XmlParser();
$xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
$admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
Context::set('cympusadmin_menu', $admin_menu);
} else {
$output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu);
if (!$output->toBool()) {
return $output;
}
Context::set('cympusadmin_menu', $manager_menu);
}
$news = getNewsFromAgency();
Context::set('news', $news);
Context::set('admin_bar', 'false');
$oModuleModel =& getModel('module');
$module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
Context::set('cympus_modinfo', $module_info);
return new Object();
}
开发者ID:WEN2ER,项目名称:nurigo,代码行数:32,代码来源:cympusadmin.class.php
示例5: checkEasyinstall
/**
* check easy install
* @return void
*/
function checkEasyinstall()
{
$lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile);
if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) {
return;
}
$oAutoinstallModel = getModel('autoinstall');
$params = array();
$params["act"] = "getResourceapiLastupdate";
$body = XmlGenerater::generate($params);
$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
$xml_lUpdate = new XmlParser();
$lUpdateDoc = $xml_lUpdate->parse($buff);
$updateDate = $lUpdateDoc->response->updatedate->body;
if (!$updateDate) {
$this->_markingCheckEasyinstall();
return;
}
$item = $oAutoinstallModel->getLatestPackage();
if (!$item || $item->updatedate < $updateDate) {
$oController = getAdminController('autoinstall');
$oController->_updateinfo();
}
$this->_markingCheckEasyinstall();
}
开发者ID:kkkyyy03,项目名称:coffeemix,代码行数:29,代码来源:admin.admin.view.php
示例6: getNewsFromAgency
function getNewsFromAgency()
{
//Retrieve recent news and set them into context
$newest_news_url = sprintf("http://www.xeshoppingmall.com/?module=newsagency&act=getNewsagencyArticle&inst=notice&top=6&loc=%s", _XE_LOCATION_);
$cache_file = sprintf("%sfiles/cache/nstore_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) {
// Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page
// Ensure to access the textmessageistration page even though news cannot be displayed
FileHandler::writeFile($cache_file, '');
FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl('')));
}
if (file_exists($cache_file)) {
$oXml = new XmlParser();
$buff = $oXml->parse(FileHandler::readFile($cache_file));
$item = $buff->zbxe_news->item;
if ($item) {
if (!is_array($item)) {
$item = array($item);
}
foreach ($item as $key => $val) {
$obj = null;
$obj->title = $val->body;
$obj->date = $val->attrs->date;
$obj->url = $val->attrs->url;
$news[] = $obj;
}
return $news;
}
}
}
开发者ID:umjinsun12,项目名称:dngshin,代码行数:30,代码来源:functions.php
示例7: init
function init()
{
// forbit access if the user is not an administrator
$oMemberModel =& getModel('member');
$logged_info = $oMemberModel->getLoggedInfo();
if ($logged_info->is_admin != 'Y') {
return $this->stop("msg_is_not_administrator");
}
// change into administration layout
//$this->setTemplatePath('./modules/cympusadmin/tpl');
$this->setLayoutPath('./modules/cympusadmin/tpl');
$this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
// parse admin menu
$act = Context::get('act');
$oXmlParser = new XmlParser();
$xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
$admin_menu = array();
$admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
Context::set('cympusadmin_menu', $admin_menu);
$oModuleModel =& getModel('module');
$module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
Context::set('cympus_modinfo', $module_info);
$news = getNewsFromAgency();
Context::set('news', $news);
Context::set('admin_bar', 'false');
}
开发者ID:umjinsun12,项目名称:dngshin,代码行数:26,代码来源:cympusadmin.class.php
示例8: getLogs
/**
* get logs of the log file
* @param $type string of log direcroty, like store
* @param $logFile - log files name like 12.27.2009.xml
* @param $userID
* @author Oleg D.
*/
function getLogs($type, $logFile, $userID = null)
{
$logFile .= '.xml';
$date = explode('.', $logFile);
$year = $date[2];
$month = $date[0];
App::import('Vendor', 'XmlParser', array('file' => 'xmlparser.class.php'));
$XmlParser = new XmlParser();
$file = file_get_contents(ROOT . DS . 'app' . DS . 'logs' . DS . $type . DS . $year . DS . $month . DS . $logFile);
$file = str_replace('&', 'and', $file);
if (!$file) {
echo 'file error';
exit;
}
$file = '<All>' . $file . '</All>';
$logsParse = $XmlParser->xml2array($file);
$logs = array();
if (isset($logsParse['All']['Log'])) {
$logs = $logsParse['All']['Log'];
}
if ($userID) {
$myLogs = array();
foreach ($logs as $log) {
if ($log['Uid'] == $userID) {
$myLogs[] = $log;
}
}
} else {
$myLogs = $logs;
}
$myLogs = array_reverse($myLogs);
//echo "<pre>";
//print_r($myLogs);
return $myLogs;
}
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:42,代码来源:LoggerComponent.php
示例9: getLicenseFromAgency
function getLicenseFromAgency($prodid, &$has_license = TRUE, &$expiration = NULL)
{
$has_license = TRUE;
$oLicenseModel =& getModel('license');
$config = $oLicenseModel->getModuleConfig();
if ($prodid == 'nstore') {
$user_id = $config->user_id;
$serial_number = $config->serial_number;
} else {
if ($prodid == 'nstore_digital') {
$user_id = $config->d_user_id;
$serial_number = $config->d_serial_number;
} else {
$user_id = $config->e_user_id;
$serial_number = $config->e_serial_number;
}
}
$cache_file = $this->checkLicense($prodid, $user_id, $serial_number);
if (file_exists($cache_file)) {
$oXml = new XmlParser();
$buff = $oXml->parse(FileHandler::readFile($cache_file));
// user
$userObj = $buff->drm->user;
if ($userObj) {
$user = $userObj->body;
if ($user != $user_id) {
$this->checkLicense($prodid, $user_id, $serial_number, TRUE);
return TRUE;
}
}
// serial
$serialObj = $buff->drm->serial;
if ($serialObj) {
$serial = $serialObj->body;
if ($serial != $serial_number) {
$this->checkLicense($prodid, $user_id, $serial_number, TRUE);
return TRUE;
}
}
// license
$licenseObj = $buff->drm->license;
if ($licenseObj) {
$license = $licenseObj->body;
if ($license == 'none') {
$url = getUrl('act', 'dispLicenseAdminConfig');
Context::set(sprintf('%s_MESSAGE_TYPE', strtoupper($prodid)), 'error');
Context::set(sprintf('%s_MESSAGE', strtoupper($prodid)), Context::getLang('not_registered'));
$has_license = FALSE;
}
}
// expiration
$expirationObj = $buff->drm->expiration;
if ($expirationObj) {
$expiration = $expirationObj->body;
}
}
return FALSE;
}
开发者ID:WEN2ER,项目名称:nurigo,代码行数:58,代码来源:license.model.php
示例10: loadXmlFile
/**
* Load a xml file specified by a filename and parse it to Return the resultant data object
* @param string $filename a file path of file
* @return array Returns a data object containing data extracted from a xml file or NULL if a specified file does not exist
*/
function loadXmlFile($filename)
{
if (!file_exists($filename)) {
return;
}
$buff = FileHandler::readFile($filename);
$oXmlParser = new XmlParser();
return $oXmlParser->parse($buff);
}
开发者ID:kimkucheol,项目名称:xe-core,代码行数:14,代码来源:XmlParser.class.php
示例11: decompressFile
public static function decompressFile($file, $destination = NULL)
{
if (!is_file($file)) {
throw new Exception("{$file} is not a regular file");
}
$parser = new XmlParser(new Stream(fopen($file, 'rd')));
//TODO : write a method in this class, ->saveToFile();
file_put_contents($destination === NULL ? $file : $destination, $parser->getXmlString());
}
开发者ID:WebApps4u,项目名称:lwappstore,代码行数:9,代码来源:XmlParser.php
示例12: _setGrantByWidgetSequence
function _setGrantByWidgetSequence($matches)
{
$buff = trim($matches[0]);
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse(trim($buff));
$widget_sequence = $vars->widget_sequence;
if ($widget_sequence) {
$_SESSION['magic_content_grant'][$widget_sequence] = true;
}
}
开发者ID:ilbecms,项目名称:xe_module_magiccontent,代码行数:10,代码来源:magiccontent.controller.php
示例13: getXmlDoc
/**
* Request data to server and returns result
*
* @param array $params Request data
* @return object
*/
function getXmlDoc(&$params)
{
$body = XmlGenerater::generate($params);
$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
if (!$buff) {
return;
}
$xml = new XmlParser();
$xmlDoc = $xml->parse($buff);
return $xmlDoc;
}
开发者ID:kimkucheol,项目名称:xe-core,代码行数:17,代码来源:autoinstall.class.php
示例14: getXmlDoc
/**
* Request data to server and returns result
*
* @param array $params Request data
* @return object
*/
function getXmlDoc(&$params)
{
$body = XmlGenerater::generate($params);
$request_config = array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE);
$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml", array(), array(), array(), $request_config);
if (!$buff) {
return;
}
$xml = new XmlParser();
$xmlDoc = $xml->parse($buff);
return $xmlDoc;
}
开发者ID:rhymix,项目名称:rhymix,代码行数:18,代码来源:autoinstall.class.php
示例15: search_address
/**
* @brief naver map open api에서 주소를 찾는 함수
**/
function search_address()
{
$address = Context::get('address');
if (!$address) {
return new Object(-1, 'msg_not_exists_addr');
}
Context::loadLang($this->component_path . "lang");
// 지정된 서버에 요청을 시도한다
$address = urlencode(iconv("UTF-8", "EUC-KR", $address));
$query_string = sprintf('/api/geocode.php?key=%s&query=%s', $this->api_key, $address);
$fp = fsockopen('maps.naver.com', 80, $errno, $errstr);
if (!$fp) {
return new Object(-1, 'msg_fail_to_socket_open');
}
fputs($fp, "GET {$query_string} HTTP/1.0\r\n");
fputs($fp, "Host: maps.naver.com\r\n\r\n");
$buff = '';
while (!feof($fp)) {
$str = fgets($fp, 1024);
if (trim($str) == '') {
$start = true;
}
if ($start) {
$buff .= trim($str);
}
}
fclose($fp);
$buff = trim(iconv("EUC-KR", "UTF-8", $buff));
$buff = str_replace('<?xml version="1.0" encoding="euc-kr" ?>', '', $buff);
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($buff);
//If a Naver OpenApi Error message exists.
if ($xml_doc->error->error_code->body || $xml_doc->error->message->body) {
return new Object(-1, 'NAVER OpenAPI Error' . "\n" . 'Code : ' . $xml_doc->error->error_code->body . "\n" . 'Message : ' . $xml_doc->error->message->body);
}
if ($xml_doc->geocode->total->body == 0) {
return new Object(-1, 'msg_no_result');
}
$addrs = $xml_doc->geocode->item;
if (!is_array($addrs)) {
$addrs = array($addrs);
}
$addrs_count = count($addrs);
$address_list = array();
for ($i = 0; $i < $addrs_count; $i++) {
$item = $addrs[$i];
$address_list[] = sprintf("%s,%s,%s", $item->point->x->body, $item->point->y->body, $item->address->body);
}
$this->add("address_list", implode("\n", $address_list));
}
开发者ID:hottaro,项目名称:xpressengine,代码行数:53,代码来源:naver_map.class.php
示例16: init
function init($module = null)
{
// change into administration layout
$config = getModel('cympusadmin')->getConfig();
$args = new stdClass();
$args->module = 'cympusadmin';
$module_list = getModel('module')->getModuleSrlList($args);
if (!empty($module_list)) {
foreach ($module_list as $module_info) {
$cympus_module_info = $module_info;
}
}
$module_path = './modules/cympusadmin/';
$template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin);
if (!is_dir($template_path) || !$cympus_module_info->skin) {
$config->admin_skins = 'default';
$template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin);
}
if ($module) {
$module->setLayoutPath($template_path);
$module->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
} else {
$this->setLayoutPath($template_path);
$this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
}
Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/');
$logged_info = Context::get('logged_info');
if ($logged_info->is_admin == 'Y') {
// parse admin menu
$oXmlParser = new XmlParser();
$xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
$admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
Context::set('cympusadmin_menu', $admin_menu);
} else {
$output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu);
if (!$output->toBool()) {
return $output;
}
Context::set('cympusadmin_menu', $manager_menu);
}
$news = getNewsFromAgency();
Context::set('news', $news);
Context::set('admin_bar', 'false');
$oModuleModel = getModel('module');
$module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
Context::set('cympus_modinfo', $module_info);
return new Object();
}
开发者ID:bjrambo,项目名称:nurigo,代码行数:48,代码来源:cympusadmin.class.php
示例17: fetchArmory
/**
* General armory fetch class
* Returns XML, HTML or an array of the parsed XML page
*
* @param int $type
* @param string $character
* @param string $guild
* @param string $realm
* @param int $item_id
* @param string $fetch_type
* @return array
*/
function fetchArmory($type = false, $character = false, $guild = false, $realm = false, $item_id = false, $fetch_type = 'array')
{
global $roster;
$url = $this->_makeUrl($type, false, $item_id, $character, $realm, $guild);
if ($fetch_type == 'html') {
$this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
}
if ($this->_requestXml($url)) {
if ($fetch_type == 'array') {
// parse and return array
$this->_initXmlParser();
$this->xmlParser->Parse($this->xml);
$data = $this->xmlParser->getParsedData();
} elseif ($fetch_type == 'simpleClass') {
// parse and return SimpleClass object
$this->_initSimpleParser();
$data = $this->simpleParser->parse($this->xml);
} else {
// unparsed fetches
return $this->xml;
}
return $data;
} else {
trigger_error('RosterArmory:: Failed to fetch ' . $url);
return false;
}
}
开发者ID:Sajaki,项目名称:addons,代码行数:39,代码来源:armory.class.php
示例18: renderUI
public static function renderUI($action)
{
$action->user_id = $action->getUser()->getAppFlowerUser()->getId();
if (class_exists("GraphUtil")) {
$setting = GraphUtil::getDefaultSettingByName($action->name);
}
$action->id = '';
$c = new Criteria();
$c->add(afWidgetSettingPeer::USER, $action->user_id);
$c->add(afWidgetSettingPeer::NAME, $action->name);
$obj = afWidgetSettingPeer::doSelectOne($c);
if ($obj) {
$action->id = $obj->getId();
$setting = json_decode($obj->getSetting(), true);
}
$varHolder = array();
if (is_array($setting)) {
foreach ($setting as $k => $v) {
if (is_array($v)) {
foreach ($v as $kk => $vv) {
$varHolder[$k . "_" . $kk] = $vv;
}
} else {
$varHolder[$k] = $v;
}
}
}
$action->getVarHolder()->add($varHolder);
return XmlParser::layoutExt($action);
}
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:30,代码来源:afWidgetSettingPeer.php
示例19: getTableInfo
/**
* Returns table information
*
* Used for finding column type info (string/numeric) <br />
* Obtains the table info from XE's XML schema files
*
* @param object $query_id
* @param bool $table_name
* @return array
*/
function getTableInfo($query_id, $table_name)
{
$column_type = array();
$module = '';
$id_args = explode('.', $query_id);
if (count($id_args) == 2) {
$target = 'modules';
$module = $id_args[0];
$id = $id_args[1];
} else {
if (count($id_args) == 3) {
$target = $id_args[0];
$targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1);
if (!isset($targetList[$target])) {
return;
}
$module = $id_args[1];
$id = $id_args[2];
}
}
// get column properties from the table
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
if (!file_exists($table_file)) {
$searched_list = FileHandler::readDir(_XE_PATH_ . 'modules');
$searched_count = count($searched_list);
for ($i = 0; $i < $searched_count; $i++) {
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name);
if (file_exists($table_file)) {
break;
}
}
}
if (file_exists($table_file)) {
$table_xml = FileHandler::readFile($table_file);
$xml_parser = new XmlParser();
$table_obj = $xml_parser->parse($table_xml);
if ($table_obj->table) {
if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) {
$table_obj->table->column = array($table_obj->table->column);
}
foreach ($table_obj->table->column as $k => $v) {
$column_type[$v->attrs->name] = $v->attrs->type;
}
}
}
return $column_type;
}
开发者ID:rhymix,项目名称:rhymix,代码行数:57,代码来源:QueryParser.class.php
示例20: parse
/**
* Converts XML into an array, respecting namespaces, attributes, and text values.
*
* @return array
*/
public function parse()
{
$namespaces = $this->xml->getDocNamespaces();
$namespaces[''] = null;
//add base (empty) namespace
$attributes = $this->getAttributes($namespaces);
//get child nodes from all namespaces
$tags = array();
foreach ($namespaces as $prefix => $namespace) {
foreach ($this->xml->children($namespace) as $childXml) {
$new_parser = new XmlParser($childXml, $this->options);
$child = $new_parser->parse();
list($childTag, $childProperties) = each($child);
//add namespace prefix, if any
if ($prefix) {
$childTag = $prefix . $this->namespaceSeparator . $childTag;
}
if (!isset($tags[$childTag])) {
$alwaysArray = $this->options['alwaysArray'];
$autoArray = $this->options['autoArray'];
$tags[$childTag] = $childProperties;
if (in_array($childTag, $alwaysArray) || !$autoArray) {
$tags[$childTag] = [$childProperties];
}
} elseif ($this->isIntegerIndexedArray($tags[$childTag])) {
$tags[$childTag][] = $childProperties;
} else {
//key exists so convert to integer indexed array with previous value in position 0
$tags[$childTag] = array($tags[$childTag], $childProperties);
}
}
}
//get text content of node
$textContent = array();
$plainText = trim((string) $this->xml);
if ($plainText !== '') {
$textContent[$this->options['textContent']] = $plainText;
}
//stick it all together
$properties = $plainText;
if (!$this->options['autoText'] || $attributes || $tags || $plainText === '') {
$properties = array_merge($attributes, $tags, $textContent);
}
//return node as array
return array($this->xml->getName() => $properties);
}
开发者ID:brianseitel,项目名称:ook,代码行数:51,代码来源:XmlParser.php
注:本文中的XmlParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论