本文整理汇总了PHP中XmlParser::xml2array方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlParser::xml2array方法的具体用法?PHP XmlParser::xml2array怎么用?PHP XmlParser::xml2array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlParser
的用法示例。
在下文中一共展示了XmlParser::xml2array方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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;
}
示例2: 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;
}
示例3: loadFromData
/**
* 从XML文件读取信息
* @param string $data XML数据
* @param string $startNode 返回结果的起始节点
* @return array 返回XML内容数组
*/
function loadFromData($data, $startNode = '')
{
if (isset($data)) {
$xml = XmlParser::xml2array($data);
if ($startNode) {
$startNode = explode('/', $startNode);
foreach ($startNode as $node) {
}
$xml = isset($xml[$node]) ? $xml = $xml[$node] : array();
}
} else {
$xml = array();
}
return $xml;
}
示例4: cronUpdateVideoStatus
/**
* CRON update video process status
* @author Oleg D.
*/
function cronUpdateVideoStatus()
{
Configure::write('debug', 1);
// set is_processed for all videos who uploaded mor then 15 minutes ago
$sql = "UPDATE videos SET is_processed = 1 WHERE uploaded AND is_processed = 0 AND uploaded < date_add(now(), interval -25 minute)";
$this->Video->query($sql);
App::import('Vendor', 'XmlParser', array('file' => 'xmlparser.class.php'));
$XmlParser = new XmlParser();
$videos = $this->Video->find('all', array('conditions' => array('is_processed' => 0, 'is_deleted' => 0, 'is_file' => 1, 'youtube_id is not null')));
//pr($videos);
foreach ($videos as $video) {
if ($video['Video']['youtube_id']) {
$content = $this->file_get_contents_curl('http://gdata.youtube.com/feeds/api/videos/' . $video['Video']['youtube_id']);
$ansverArray = $XmlParser->xml2array($content);
if (!empty($ansverArray['entry'])) {
if (!empty($ansverArray['entry']['app:control']['yt:state_attr'])) {
//echo "processing";
echo $video['Video']['youtube_id'] . ' - ' . 'processing<br/>';
} else {
//echo "processing finished";
$this->Video->save(array('id' => $video['Video']['id'], 'is_processed' => 1));
echo $video['Video']['youtube_id'] . ' - ' . 'processed<br/>';
}
}
}
}
Cache::delete('last_videos');
exit;
}
示例5: getTwitterInfo
/**
* Get Twitter information
* @author Oleg D.
*/
function getTwitterInfo($twitterID)
{
App::import('Vendor', 'XmlParser', array('file' => 'xmlparser.class.php'));
$XmlParser = new XmlParser();
for ($i = 0; $i < 5; $i++) {
$info = $this->file_get_contents_curl('http://api.twitter.com/1/users/show.xml?user_id=' . $twitterID);
$info = $XmlParser->xml2array($info);
if (!empty($info['user']['id'])) {
break;
}
}
if (!empty($info['user'])) {
$info = $info['user'];
} else {
return false;
}
return $info;
}