当前位置: 首页>>代码示例>>PHP>>正文


PHP simpleXML_load_file函数代码示例

本文整理汇总了PHP中simpleXML_load_file函数的典型用法代码示例。如果您正苦于以下问题:PHP simpleXML_load_file函数的具体用法?PHP simpleXML_load_file怎么用?PHP simpleXML_load_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了simpleXML_load_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: interXML

/**
 * 追加接口参数,支持过滤成功用例
 * @param unknown_type $onlyfails
 */
function interXML($onlyfails)
{
    if (!file_exists('report.xml')) {
        return array();
    }
    $xmlFile = simpleXML_load_file("report.xml");
    $caseList = array();
    foreach ($xmlFile->testsuite as $testsuite) {
        foreach ($testsuite->testcase as $testResult) {
            //			$totalCov = 0;
            $browser = strval($testResult['browserInfo']);
            $host = strval($testResult['hostInfo']);
            $caseName = strval($testResult['name']);
            $fail = strval($testResult['failNumber']);
            $total = strval($testResult['totalNumber']);
            $cov = strval($testResult['cov']);
            $recordCovForBrowser = strval($testResult['recordCovForBrowser']);
            if (!array_key_exists($caseName, $caseList)) {
                //如果这个用例不存在
                $caseInfo = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser);
                //				$totalCov += $cov;
                $caseList[$caseName] = array($browser => $caseInfo);
                //				$caseList['totalCov'] = $totalCov;
            } else {
                //否则添加到相应的用例中去
                $foundCase = $caseList[$caseName];
                //找到用例名称对应的array,$caseName为key
                if (!array_key_exists($browser, $foundCase)) {
                    //如果没有该浏览器信息,则添加
                    //					$totalCov += $cov;
                    $caseList[$caseName][$browser] = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser);
                    //					$caseList[$caseName]['totalCov'] = $totalCov;
                } else {
                    $foundBrowser = $foundCase[$browser];
                    //有这个浏览器
                    array_push($foundBrowser, array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser));
                }
            }
        }
    }
    //根据需求添加仅记录失败情况的接口
    if ($onlyfails) {
        //如果仅考虑失败情况,此处根据用例情况过滤
        foreach ($caseList as $name => $info) {
            $all_success = true;
            //记录当前用例是否全部运行成功
            foreach ($info as $b => $result) {
                if ($result['fail'] > 0) {
                    $all_success = false;
                }
                //如果有失败情况则终止循环并进入下一个用例分析
                break;
            }
            //if($all_success) //如果全部通过则从记录中移除
            //unset($caseList[$name]);
        }
    }
    return $caseList;
}
开发者ID:ezhangle,项目名称:sui-editor,代码行数:63,代码来源:record.php

示例2: process

 public static function process()
 {
     $xml = simpleXML_load_file(self::$xmlFile, "SimpleXMLElement", LIBXML_NOCDATA);
     foreach ($xml->Offers->Item as $Item) {
         foreach ($Item->Images->Image as $image) {
             self::getImage($image);
         }
     }
 }
开发者ID:jjechev,项目名称:tools,代码行数:9,代码来源:imgxmldownloader.php

示例3: parse_xml

 /**
  * 
  * @param type $url
  * @return Object of parsed XML
  */
 function parse_xml($url)
 {
     try {
         $weather_object = simpleXML_load_file($url, "SimpleXMLElement", LIBXML_NOCDATA);
         if ($weather_object === FALSE) {
             return false;
         } else {
             return $weather_object;
         }
     } catch (Exception $ex) {
         echo 'Error Parsing XML ', $e->getMessage(), "\n";
     }
 }
开发者ID:weborion,项目名称:weatherxmlparse,代码行数:18,代码来源:index.php

示例4: processXML

 function processXML($URL)
 {
     try {
         $file_headers = @get_headers($URL);
         if ($file_headers[0] != 'HTTP/1.1 404 Not Found') {
             return simpleXML_load_file($URL, "SimpleXMLElement", LIBXML_NOCDATA);
         } else {
             throw new Exception('Stations file not currently available from NOAA.');
             return false;
         }
     } catch (Exception $e) {
         echo "Error thrown: " . $e->getMessage();
         return false;
     }
 }
开发者ID:kelen303,项目名称:iEMS,代码行数:15,代码来源:weatherTest.php

示例5: get_legend

function get_legend($filename_main_kml)
{
    global $template, $user;
    //Parser
    $xml = simpleXML_load_file($filename_main_kml);
    if ($user->data['user_id'] == 2) {
        //print_r($xml);
    }
    if ($xml === FALSE) {
        return;
    } else {
        $color = get_color_array($xml);
        $color_arry_size = count($color);
        //echo($color[0]['color'] . ' - ' . $color[1]['color']. ' - ' . $color[2]['color']);
        $i = 0;
        if ($xml->Document->Placemark) {
            foreach ($xml->Document->Placemark as $value) {
                if ($value->name) {
                    if ($value->styleUrl) {
                        $style = substr($value->styleUrl, 1);
                        for ($z = 0; $z < $color_arry_size; $z++) {
                            if ($user->data['user_id'] == 2) {
                                //	echo($z. ' ' . $color[$z]['id'] . ' ' .$color[$z]['img'] . '<br>');
                            }
                            if ($style == $color[$z]['id']) {
                                $data[$i]['color'] = $color[$z]['color'];
                                $data[$i]['img'] = $color[$z]['img'];
                            }
                        }
                    }
                    $data[$i]['text'] = $value->name;
                    $i++;
                }
            }
        }
    }
    $count_data = sizeof($data);
    // Output
    for ($i = 0; $i < $count_data; $i++) {
        $color = $data[$i]['color'];
        $text = $data[$i]['text'];
        $template->assign_block_vars('legend', array('COLOR' => $color, 'TEXT' => $text, 'S_IMG' => $data[$i]['img']));
    }
    return $count_data;
}
开发者ID:velocat,项目名称:phpbb3,代码行数:45,代码来源:functions_marshrut.php

示例6: LoadFromFile

 public static function LoadFromFile($pathFile)
 {
     $saoData = new SaoDatabase();
     $listBinhChu = array();
     $xmlData = simpleXML_load_file($pathFile);
     foreach ($xmlData->children() as $binhChu) {
         try {
             $saosNode = $binhChu->Saos;
             $cungsNode = $binhChu->Cungs;
             $lthansNode = $binhChu->LucThans;
             $lbinh = $binhChu->LoiBinh;
             $saos = array();
             $cungs = array();
             $lthans = array();
             $CSData = $saoData->CSData;
             if (isset($saosNode->Sao)) {
                 foreach ($saosNode->Sao as $sao) {
                     $ID = intval(BinhChu::xml_attribute($sao, 'ID'));
                     if (isset($CSData[$ID - 1])) {
                         array_push($saos, $CSData[$ID - 1]);
                     }
                 }
             }
             if (isset($saosNode->Cung)) {
                 foreach ($cungsNode->Cung as $cung) {
                     $ID = intval(BinhChu::xml_attribute($cung, 'ID'));
                     array_push($cungs, $ID);
                 }
             }
             if (isset($saosNode->LucThan)) {
                 foreach ($lthansNode->LucThan as $lucthan) {
                     $ID = intval(BinhChu::xml_attribute($lucthan, 'ID'));
                     array_push($lthans, $ID);
                 }
             }
             if (count($saos) > 0 || count($cungs) > 0 || count($lthans) > 0) {
                 array_push($listBinhChu, new BinhChu($saos, $cungs, $lthans, $lbinh));
             }
         } catch (Exception $e) {
         }
     }
     return $listBinhChu;
 }
开发者ID:vothienhoa,项目名称:tuvi,代码行数:43,代码来源:BinhChu.php

示例7: getInfos

 /**
  * Récupère les informations d'un album d'après son titre et son artiste ou de l'ID
  * @param string $p_sAlbum
  * @param string $p_sArtist
  * @return \LASTFM\Album Un objet contenant l'album
  */
 public function getInfos($p_sAlbum, $p_sArtist, $p_sMbId = null)
 {
     if ($p_sMbId == null) {
         $sParams = '&artist=' . rawurlencode($p_sArtist) . '&album=' . rawurlencode($p_sAlbum);
     } else {
         $sParams = '&mbid=' . $p_sMbId;
     }
     if (!($oRssDoc = simpleXML_load_file($this->sBaseUrl . '?method=album.getinfo&api_key=' . $this->sApiKey . $sParams, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_NOWARNING))) {
         return null;
     }
     if ($oRssDoc->album->mbid == '') {
         return null;
     }
     $oAlbum = new Album($oRssDoc->album->name, $oRssDoc->album->artist, $oRssDoc->album->mbid);
     $oAlbum->setDate(date("Y-m-j G:i:s", strtotime($oRssDoc->album->releasedate)));
     $oAlbum->setCover($oRssDoc->album->image[4]);
     foreach ($oRssDoc->album->tracks->track as $oRssTrack) {
         $oAlbum->addTrack($oRssTrack->attributes()[0]->__toString(), $oRssTrack->name, $oRssTrack->duration);
     }
     return $oAlbum;
 }
开发者ID:Jatax,项目名称:TKS,代码行数:27,代码来源:LastFM.class.php

示例8: getTCPDFFontsList

 /**
  * Retrieve a list of available fonts to be used with PDF Invoice generation & PDF Product view on FE
  *
  * @author Nikos Zagas
  * @return object List of available fonts
  */
 function getTCPDFFontsList()
 {
     $dir = VMPATH_ROOT . DS . 'libraries' . DS . 'tcpdf' . DS . 'fonts';
     $result = array();
     if (function_exists('glob')) {
         $specfiles = glob($dir . DS . "*_specs.xml");
         /*if(empty($specfiles) and is_dir($dir)){
         			vmWarn('No fonts _specs.xml files found in '.$dir);
         		}*/
     } else {
         $specfiles = array();
         $manual = array('courier_specs.xml', 'freemono_specs.xml', 'helvetica_specs.xml');
         foreach ($manual as $file) {
             if (file_exists($dir . DS . $file)) {
                 $specfiles[] = $dir . DS . $file;
             }
         }
     }
     if (empty($specfiles)) {
         $manual = array('courier', 'freemono', 'helvetica');
         foreach ($manual as $file) {
             if (file_exists($dir . DS . $file . '.php')) {
                 $result[] = JHtml::_('select.option', $file, vmText::_($file . ' (standard)'));
             }
         }
     } else {
         foreach ($specfiles as $file) {
             $fontxml = @simpleXML_load_file($file);
             if ($fontxml) {
                 if (file_exists($dir . DS . $fontxml->filename . '.php')) {
                     $result[] = JHtml::_('select.option', $fontxml->filename, vmText::_($fontxml->fontname . ' (' . $fontxml->fonttype . ')'));
                 } else {
                     vmError('A font master file is missing: ' . $dir . DS . $fontxml->filename . '.php');
                 }
             } else {
                 vmError('Wrong structure in font XML file: ' . $dir . DS . $file);
             }
         }
     }
     return $result;
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:47,代码来源:config.php

示例9: die

} else {
    die("Need to pass the 'access_key' URL parameter");
}
try {
    /*  query the database */
    // $db = getCon();
    $db = mysql_connect($db_hostname, $db_username, $db_password);
    if (!$db) {
        die("Could not connect: " . mysql_error());
    }
    mysql_select_db("your_db", $db);
    echo "Starting to work with feed URL '" . $feed_url . "'";
    /* Parse XML from  http://www.instapaper.com/starred/rss/580483/qU7TKdkHYNmcjNJQSMH1QODLc */
    //$RSS_DOC = simpleXML_load_file('http://www.instapaper.com/starred/rss/580483/qU7TKdkHYNmcjNJQSMH1QODLc');
    libxml_use_internal_errors(true);
    $RSS_DOC = simpleXML_load_file($feed_url);
    if (!$RSS_DOC) {
        echo "Failed loading XML\n";
        foreach (libxml_get_errors() as $error) {
            echo "\t", $error->message;
        }
    }
    /* Get title, link, managing editor, and copyright from the document  */
    $rss_title = $RSS_DOC->channel->title;
    $rss_link = $RSS_DOC->channel->link;
    $rss_editor = $RSS_DOC->channel->managingEditor;
    $rss_copyright = $RSS_DOC->channel->copyright;
    $rss_date = $RSS_DOC->channel->pubDate;
    //Loop through each item in the RSS document
    foreach ($RSS_DOC->channel->item as $RSSitem) {
        $item_id = md5($RSSitem->title);
开发者ID:sebskyman,项目名称:rssingest,代码行数:31,代码来源:index_clean.php

示例10: _saveXml

 private static function _saveXml($data, $filterNodes = false, $specificNodes = array())
 {
     $result = false;
     $canSave = false;
     if (!self::_isLocalXmlWritable()) {
         return $result;
     }
     if ($filterNodes && empty($specificNodes)) {
         return $result;
     }
     try {
         $localXml = self::_getLocalXmlPath();
         $xml = simpleXML_load_file(self::_getLocalXmlPath());
         foreach ($data as $key => $node) {
             if ($filterNodes && !isset($specificNodes[$key])) {
                 continue;
             }
             $canSave = true;
             $xParts = str_split($node['xpath'], strrpos($node['xpath'], '/'));
             $xpath = $xParts[0];
             $nodeName = ltrim($xParts[1], '/');
             $xpath = $xml->xpath($xpath);
             list($_node) = $xpath;
             $_node->{$nodeName} = NULL;
             $_node = dom_import_simplexml($_node->{$nodeName});
             $nodeOwner = $_node->ownerDocument;
             $_node->appendChild($nodeOwner->createCDATASection($node['value']));
         }
         if ($canSave) {
             $xmlContent = $xml->asXML();
             $result = file_put_contents($localXml, $xmlContent);
         }
     } catch (Exception $e) {
     }
     return $result;
 }
开发者ID:shopgo-magento1,项目名称:loxgen,代码行数:36,代码来源:LoxGen.php

示例11: foreach

 * meant to be used as a cron job
 *
 * @package    SlimRSS
 * @author     AdamGold <adamgold7@gmail.com>
 * @copyright  2015 AdamGold
 */
require 'config.php';
require HOME . '/vendor/autoload.php';
$modelFactory = new \Core\ModelFactory();
$pdo = $modelFactory::$connection;
$sth = $pdo->prepare('SELECT * FROM ' . DB_PREFIX . 'channels ORDER BY id DESC');
$sth->execute();
$channels = $sth->fetchAll();
foreach ($channels as $channel) {
    libxml_use_internal_errors(true);
    $rss = simpleXML_load_file($channel['link']);
    if (false === $rss) {
        // not an xml file
        continue;
    }
    $items = $rss->channel->item;
    $sth = $pdo->prepare('SELECT * FROM ' . DB_PREFIX . 'posts WHERE channel_id = ? ORDER BY date DESC');
    // last post from this channel
    $sth->execute(array($channel['id']));
    $lastPost = $sth->fetch();
    /* get categories of channel */
    $sth = $pdo->prepare('SELECT c.id FROM ' . DB_PREFIX . 'categories c JOIN ' . DB_PREFIX . 'channels_categories cr' . ' ON cr.cat_id = c.id WHERE cr.channel_id = :cid');
    $sth->bindValue(':cid', $channel['id']);
    $sth->execute();
    $cats = $sth->fetchAll();
    /* check to see if we even need to update that channel (check the last post that was published from this channel) */
开发者ID:AdamGold,项目名称:SlimRSS,代码行数:31,代码来源:rssfeed.php

示例12: _getStatus

 protected function _getStatus($zoneplayerIp)
 {
     $url = "http://" . $zoneplayerIp . ":1400/status/zp";
     $xml = simpleXML_load_file($url);
     return $xml->ZPInfo->LocalUID;
 }
开发者ID:Juanuil,项目名称:frontpage,代码行数:6,代码来源:sonos.php

示例13: parse

 /**
  * Parse le flux RSS pour trouver les Torrents
  * @param Passkey $p_oPasskey
  * @return array
  */
 public function parse($p_oPasskey)
 {
     $aTorrents = array();
     //Ouverture du flux RSS
     libxml_use_internal_errors(true);
     if ($this->isPasskey()) {
         $sUrlWithPasskey = $p_oPasskey->getLinkWithPasskey($this->sUrl);
     } else {
         $sUrlWithPasskey = $this->sUrl;
     }
     $oRssDoc = simpleXML_load_file($sUrlWithPasskey);
     if (!$oRssDoc) {
         return array('error' => "Impossible d'ouvrir le flux : " . $this->sUrl);
     }
     //Traitement des items
     foreach ($oRssDoc->channel->item as $oRssItem) {
         //Traitement des jeux de caractères
         if ($this->sEncoding === "UTF-8") {
             $sPubDate = $oRssItem->pubDate;
             $sTitle = $oRssItem->title;
             $sLink = $oRssItem->link;
         } else {
             $sPubDate = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->pubDate);
             $sTitle = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->title);
             $sLink = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->link);
         }
         //On regarde si on a une date de publication :
         if (empty($sPubDate) || $this->bForcedate) {
             $sPubDate = date("Y-m-j G:i:s");
         }
         if (strtotime($sPubDate) > strtotime($this->sLastCheck)) {
             $oTorrent = new Torrent($sTitle);
             $oTorrent->setDate(date("Y-m-j G:i:s", strtotime($sPubDate)));
             $oTorrent->setIdLink($this->getIdLink($sLink, $p_oPasskey));
             $oTorrent->setTracker($this->iTracker);
             $aTorrents[] = $oTorrent;
         }
     }
     return $aTorrents;
 }
开发者ID:Jatax,项目名称:TKS,代码行数:45,代码来源:rss.model.php

示例14: update_project_plugin_node

/**
 * Update node in axp file table 
 * @param $projName: table axp project name
 *        $tableNumber: table index inside axp file
 *        $pluginName:  plugin node to be updated
 *        $data: data to update the node with
 * @return  boolean
 */
function update_project_plugin_node($projName, $tableNumber, $pluginName, $data)
{
    @($xmlFile = simpleXML_load_file("../projects/" . $projName));
    //validate input
    if (preg_match('/^[a-z0-9-_]+\\.axp$/i', $projName) && isset($xmlFile) && isset($xmlFile->table[$tableNumber])) {
        //create spm node if not exist
        check_or_create_plugin_node($xmlFile->table[$tableNumber], $pluginName);
        $xmlFile->table[$tableNumber]->plugins->{$pluginName} = $data;
        $xmlFile->asXML("../projects/" . $projName);
        return true;
    }
    return false;
}
开发者ID:TokaMElTorkey,项目名称:northwind,代码行数:21,代码来源:plugins-common.php

示例15: processXML

 function processXML($URL)
 {
     //error_log( '== ' . microtime(true) . ' start process XML', 0, '/var/log/httpd/error_log');
     try {
         $file_headers = @get_headers($URL);
         //print $URL.'<br />';
         //print $file_headers[0].'<br />';
         if ($file_headers[0] != 'HTTP/1.1 404 Not Found') {
             return simpleXML_load_file($URL, "SimpleXMLElement", LIBXML_NOCDATA);
         } else {
             throw new Exception('Stations file not currently available from NOAA.');
         }
     } catch (Exception $e) {
         //echo "Error thrown: " . $e->getMessage();
         return false;
     }
     //error_log( '== ' . microtime(true) . ' end process XML', 0, '/var/log/httpd/error_log');
 }
开发者ID:kelen303,项目名称:iEMS,代码行数:18,代码来源:weather.inc.php


注:本文中的simpleXML_load_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。