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


PHP Xml::parse方法代码示例

本文整理汇总了PHP中Xml::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::parse方法的具体用法?PHP Xml::parse怎么用?PHP Xml::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xml的用法示例。


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

示例1: testParse

 public function testParse()
 {
     $file = __DIR__ . '/_files/xmlPhrasesForTest.xml';
     $this->xmlPhraseCollector->parse($file);
     $expectation = [['phrase' => 'Name only', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name and title space delimiter', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title1', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title2', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name only in sub node', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Text outside of attribute', 'file' => $file, 'line' => '', 'quote' => '']];
     $this->assertEquals($expectation, $this->xmlPhraseCollector->getPhrases());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:XmlTest.php

示例2: plugin_dst_xml_read

function plugin_dst_xml_read()
{
    // Perform the repository lookup and xml creation --- start
    $localFile = 'plugins/dst/countries.xml';
    $result = array('body' => file_get_contents($localFile));
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $dst_array = array();
        foreach ($xml as $file) {
            $dst_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $dst_array = $xml->parse($result);
        $dst_array = array_shift($dst_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $dst_array;
}
开发者ID:phill104,项目名称:branches,代码行数:25,代码来源:functions.inc.php

示例3: xml_unserialize

 public static function xml_unserialize(&$xml, $isnormal = FALSE)
 {
     $xml_parser = new Xml($isnormal);
     $data = $xml_parser->parse($xml);
     $xml_parser->destruct();
     return $data;
 }
开发者ID:hustshenl,项目名称:yii2-ucenter,代码行数:7,代码来源:Xml.php

示例4: index

 public function index()
 {
     $this->load->helper('directory');
     $map = directory_map(APPPATH . DS . 'modules', 1);
     // get all modules
     $module = array();
     if (count($map) > 0) {
         for ($i = 0; $i < count($map); $i++) {
             $file = APPPATH . DS . 'modules' . DS . $map[$i] . DS . $map[$i] . '.xml';
             if (file_exists($file)) {
                 $module[] = $map[$i];
             }
         }
     }
     // load modules info
     $this->load->library('xml');
     $xml = new Xml();
     $modules = array();
     $j = 0;
     for ($i = 0; $i < count($module); $i++) {
         $file = APPPATH . DS . 'modules' . DS . $module[$i] . DS . $module[$i] . '.xml';
         $data = $xml->parse($file);
         if (isset($data['name']) && $data['name'] != '' && isset($data['description']) && $data['description'] != '') {
             $modules[$j] = new stdclass();
             $modules[$j]->name = $module[$i];
             $modules[$j]->title = $data['name'];
             $modules[$j]->description = $data['description'];
             $modules[$j]->thumb = 'application/modules/' . $module[$i] . '/thumb.png';
             $j++;
         }
     }
     // get page layout
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     $pages = array();
     if (count($layouts)) {
         $i = 0;
         //echo '<pre>'; print_r($layouts['group']); exit;
         foreach ($layouts['group'] as $group) {
             if (empty($group['@attributes']['description'])) {
                 continue;
             }
             $pages[$i] = new stdClass();
             $pages[$i]->name = $group['@attributes']['name'];
             $pages[$i]->description = $group['@attributes']['description'];
             if (empty($group['@attributes']['icon']) || $group['@attributes']['icon'] == '') {
                 $pages[$i]->icon = base_url('assets/images/system/home.png');
             } else {
                 $pages[$i]->icon = base_url('assets/images/system/' . $group['@attributes']['icon']);
             }
             $i++;
         }
     }
     $this->data['pages'] = $pages;
     $this->data['modules'] = $modules;
     $this->load->view('admin/module/index', $this->data);
 }
开发者ID:Nnamso,项目名称:tbox,代码行数:59,代码来源:module.php

示例5: test_parse_returnsTrue_ifOutputIsValidXml

 /**
  * parse() should return true if output if well-formed xml
  */
 public function test_parse_returnsTrue_ifOutputIsValidXml()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<foo>' . '<bar>' . 'baz' . '</bar>' . '<bar>' . 'qux' . '</bar>' . '</foo>';
     $data = ['bar' => ['baz', 'qux']];
     $response = new Xml();
     $this->assertTrue($response->parse($xml));
     $this->assertEquals($data, $response->getData());
     return;
 }
开发者ID:jstewmc,项目名称:api,代码行数:12,代码来源:XmlTest.php

示例6: add

 public function add($id = null)
 {
     $this->data['breadcrumb'] = lang('layout_add');
     $this->data['meta_title'] = lang('layout_add');
     $this->data['sub_title'] = 'Drag and drop to add element after click "save"';
     // get all layouts
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     if (count($layouts)) {
         $arr = array();
         foreach ($layouts['group'] as $key => $group) {
             $arr[$group['@attributes']['name']] = array();
             if ($group['layout']) {
                 if (isset($group['layout'][0]) == true) {
                     foreach ($group['layout'] as $layout) {
                         $arr[$group['@attributes']['name']][$layout['name']] = array();
                         $arr[$group['@attributes']['name']][$layout['name']]['title'] = $layout['title'];
                         $arr[$group['@attributes']['name']][$layout['name']]['description'] = $layout['description'];
                     }
                 } else {
                     $arr[$group['@attributes']['name']][$group['layout']['name']] = array();
                     $arr[$group['@attributes']['name']][$group['layout']['name']]['title'] = $group['layout']['title'];
                     $arr[$group['@attributes']['name']][$group['layout']['name']]['description'] = $group['layout']['description'];
                 }
             }
         }
     }
     //echo '<pre>'; print_r($arr); exit;
     $this->data['layouts'] = $arr;
     // load data
     if ($id == null) {
         $layout = $this->layout_m->getNew();
     } else {
         $layout = $this->layout_m->get($id);
     }
     $this->data['page'] = $layout;
     $this->data['subview'] = 'admin/layout/add';
     $this->load->view('admin/_layout_main', $this->data);
 }
开发者ID:Nnamso,项目名称:tbox,代码行数:41,代码来源:layout.php

示例7: cpgVersioncheckConnectRepository

function cpgVersioncheckConnectRepository()
{
    global $displayOption_array, $majorVersion;
    // Perform the repository lookup and xml creation --- start
    //$displayOption_array['do_not_connect_to_online_repository'] = 1;
    $remoteURL = 'http://coppermine-gallery.net/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $localFile = 'include/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $remoteConnectionFailed = '';
    if ($displayOption_array['do_not_connect_to_online_repository'] == 0) {
        // connect to the online repository --- start
        $result = cpgGetRemoteFileByURL($remoteURL, 'GET', '', '200');
        if (strlen($result['body']) < 2000) {
            $remoteConnectionFailed = 1;
            $error = $result['error'];
        }
    }
    // connect to the online repository --- end
    if ($displayOption_array['do_not_connect_to_online_repository'] == 1 || $remoteConnectionFailed == 1) {
        $result = array('body' => file_get_contents($localFile));
    }
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $file_data_array = array();
        foreach ($xml as $file) {
            $file_data_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $file_data_array = $xml->parse($result);
        $file_data_array = array_shift($file_data_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $file_data_array;
}
开发者ID:JoseCOCA,项目名称:baudprint,代码行数:40,代码来源:versioncheck.inc.php

示例8: testNumericDataHandling

 /**
  * testNumericDataHandling method
  *
  * @access public
  * @return void
  */
 function testNumericDataHandling()
 {
     $data = '<xml><data>012345</data></xml>';
     $node = new Xml();
     $node->load($data);
     $node->parse();
     $result = $node->first();
     $result = $result->children("data");
     $result = $result[0]->first();
     $this->assertEqual($result->value, '012345');
 }
开发者ID:slywalker,项目名称:CakePHPWorkshopKansai,代码行数:17,代码来源:xml.test.php

示例9: parseXML

 static function parseXML($xml)
 {
     $xml = com_wiris_util_xml_WXmlUtils::filterMathMLEntities($xml);
     $x = Xml::parse($xml);
     return $x;
 }
开发者ID:komcdo,项目名称:winnow,代码行数:6,代码来源:WXmlUtils.class.php

示例10: testParse

 public function testParse()
 {
     $expected = ['Magento\\Module1', 'Magento\\Module2'];
     $actual = $this->parser->parse(['files_for_parse' => [$this->fixtureDir . 'module1.xml', $this->fixtureDir . 'module2.xml']]);
     $this->assertEquals($expected, $actual);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:6,代码来源:XmlTest.php

示例11: cpgVersioncheckConnectRepository

function cpgVersioncheckConnectRepository($displayOption_array = '')
{
    if ($displayOption_array = '') {
        global $displayOption_array;
    }
    // Perform the repository lookup and xml creation --- start
    //$displayOption_array['do_not_connect_to_online_repository'] = 1;
    $majorVersion = 'cpg' . str_replace('.' . ltrim(substr(COPPERMINE_VERSION, strrpos(COPPERMINE_VERSION, '.')), '.'), '', COPPERMINE_VERSION) . '.x';
    $remoteURL = 'http://coppermine-gallery.net/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $localFile = 'include/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $remoteConnectionFailed = '';
    if ($displayOption_array['do_not_connect_to_online_repository'] == 0) {
        // connect to the online repository --- start
        $result = cpgGetRemoteFileByURL($remoteURL, 'GET', '', '200');
        if (strlen($result['body']) < 200) {
            $remoteConnectionFailed = 1;
            $error = $result['error'];
            //print_r($error);
            //print '<hr />';
        }
    }
    // connect to the online repository --- end
    if ($displayOption_array['do_not_connect_to_online_repository'] == 1 || $remoteConnectionFailed == 1) {
        $result = cpgGetRemoteFileByURL($localFile, 'GET', '', '200');
    }
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    include_once 'include/lib.xml.php';
    $xml = new Xml();
    $file_data_array = $xml->parse($result);
    $file_data_array = array_shift($file_data_array);
    // Perform the repository lookup and xml creation --- end
    return $file_data_array;
}
开发者ID:phill104,项目名称:branches,代码行数:36,代码来源:versioncheck.inc.php

示例12: returnNode

 /**
  * Initialize the parser by loading a file or an XML string
  *
  * @param string $strXML Name of the XML file or XML string
  * @param Xml|Bean $xmlMom Parent node
  * @param  bool $bolLoadFile Load from file or parse locally
  * @return Xml|Bean
  */
 public static function returnNode($strXML, $xmlMom, $bolLoadFile)
 {
     try {
         if ($bolLoadFile) {
             $strXML = file_get_contents($strXML);
         }
     } catch (Exception $e) {
         throw new Exception("Could not read file: " . $strXML);
     }
     if ($xmlResult = $xmlMom->parse($strXML)) {
         return $xmlResult;
     }
     throw new Exception('Could not create XML node due to an parsing error.');
 }
开发者ID:dapepe,项目名称:xily,代码行数:22,代码来源:Xml.php

示例13: __construct

 public function __construct($dbtype = null, $host = null, $port = null, $socket = null, $user = null, $pass = null, $database = null, $trase = null)
 {
     if (!php_Boot::$skip_constructor) {
         $timer = null;
         $stoptime = null;
         $profiler = system_base_Profiler::get_instance();
         $db_config = "";
         $config_path = _hx_string_or_null(system_base_Wet_base::$conf_path) . "database.xml";
         try {
             $db_config = sys_io_File::getContent($config_path);
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             throw new HException(new system_base_NoFileError(_hx_string_or_null($config_path) . " does not exist or cannot be opened for reading"));
         }
         $xml = Xml::parse($db_config);
         $config = new haxe_xml_Fast($xml->firstElement());
         if ($dbtype === null) {
             $dbtype = $config->node->resolve("type")->get_innerHTML();
         } else {
             $dbtype = $dbtype;
         }
         if ($user === null) {
             $user = $config->node->resolve("user")->get_innerHTML();
         } else {
             $user = $user;
         }
         if ($pass === null) {
             $pass = $config->node->resolve("pass")->get_innerHTML();
         } else {
             $pass = $pass;
         }
         if ($port === null) {
             $port = Std::parseInt($config->node->resolve("port")->get_innerHTML());
         } else {
             $port = $port;
         }
         if ($socket === null) {
             $socket = $config->node->resolve("socket")->get_innerHTML();
         } else {
             $socket = $socket;
         }
         if ($database === null) {
             $database = $config->node->resolve("schema")->get_innerHTML();
         } else {
             $database = $database;
         }
         $timer = new system_base_Timers(null);
         switch ($dbtype) {
             case "mysql":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "MySQL " . _hx_string_or_null($user) . "@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 115, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 try {
                     if (system_base_Database::$cnx === null) {
                         system_base_Database::$cnx = sys_db_Mysql::connect(_hx_anonymous(array("host" => $host, "port" => $port, "user" => $user, "pass" => $pass, "socket" => $socket, "database" => $database)));
                     }
                 } catch (Exception $__hx__e) {
                     $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                     $e1 = $_ex_;
                     throw new HException(new system_base_NoConnectionError($e1));
                     return;
                 }
                 $stoptime = $timer->stop();
                 break;
             case "sqlite":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if (_hx_index_of($host, "/", null) === -1) {
                     $host = _hx_string_or_null(system_base_Wet_base::$datastore_path) . _hx_string_or_null($host);
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "SQLite@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 150, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 system_base_Database::$cnx = sys_db_Sqlite::open($host);
                 $stoptime = $timer->stop();
                 break;
             default:
                 throw new HException(new system_base_NoSuchDbexception($dbtype));
                 break;
         }
         $profiler->increment("CON", $stoptime, null);
     }
 }
开发者ID:marcdraco,项目名称:Webrathea,代码行数:94,代码来源:Database.class.php

示例14: unlink

    unlink($tmpFile);
    header('Content-Disposition: attachment; filename=sacc-export.xml');
    echo $theData;
    exit;
} elseif ($type == "xml2db") {
    show_head();
    echo "<form enctype=\"multipart/form-data\" action=\"index.php?type=xmlimp\" method=\"post\">\r\n <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"3000000\" />\r\n select xml file for import: <input name=\"userfile\" type=\"file\" />\r\n <input type=\"submit\" value=\"Send File\" />\r\n</form>";
    show_tail();
    exit;
} elseif ($type == "xmlimp") {
    $uploaddir = '/tmp/';
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        echo "File {$uploadfile} successfully uploaded. ";
        $xmlr = new Xml();
        $arro = $xmlr->parse($uploadfile, 'FILE');
        unlink($uploadfile);
        $arr1 = array_pop($arro);
        $arr = array_pop($arr1);
        $arrsize = count($arr1);
        echo "<br>erase all users ";
        $req = "truncate table users";
        $result = mysql_query($req);
        echo mysql_error($link);
        echo "<br>";
        for ($i = 0; $i < $arrsize; $i++) {
            $arr = array_pop($arr1);
            echo "importing ";
            $login = addslashes($arr['login']);
            $used = $arr['used'];
            $limit = $arr['lim'];
开发者ID:digideskio,项目名称:sacc1,代码行数:31,代码来源:index.php


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