當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SimpleXMLIterator::getName方法代碼示例

本文整理匯總了PHP中SimpleXMLIterator::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleXMLIterator::getName方法的具體用法?PHP SimpleXMLIterator::getName怎麽用?PHP SimpleXMLIterator::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleXMLIterator的用法示例。


在下文中一共展示了SimpleXMLIterator::getName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unserialize

 /**
  * 
  * @return Zend_Tool_Project_Structure_Graph
  */
 public function unserialize($data)
 {
     if ($data == null) {
         throw new Exception('contents not available to unserialize.');
     }
     $xmlDataIterator = new SimpleXMLIterator($data);
     if ($xmlDataIterator->getName() != 'projectProfile') {
         throw new Exception('Profiles must start with a projectProfile node');
     }
     $this->_graph = new Zend_Tool_Project_Structure_Graph();
     $this->_unserializeRecurser($xmlDataIterator);
     return $this->_graph;
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:17,代碼來源:Xml.php

示例2: unserialize

 /**
  * unserialize()
  *
  * Create a structure in the object $profile from the structure specficied
  * in the xml string provided
  *
  * @param string xml data
  * @param Zend_Tool_Project_Profile The profile to use as the top node
  * @return Zend_Tool_Project_Profile
  */
 public function unserialize($data, Zend_Tool_Project_Profile $profile)
 {
     if ($data == null) {
         throw new Exception('contents not available to unserialize.');
     }
     $this->_profile = $profile;
     $xmlDataIterator = new SimpleXMLIterator($data);
     if ($xmlDataIterator->getName() != 'extensionProfile') {
         throw new Exception('Extension profile must start with a extensionProfile node');
     }
     if (isset($xmlDataIterator['type'])) {
         $this->_profile->setAttribute('type', (string) $xmlDataIterator['type']);
     }
     if (isset($xmlDataIterator['version'])) {
         $this->_profile->setAttribute('version', (string) $xmlDataIterator['version']);
     }
     // start un-serialization of the xml doc
     $this->_unserializeRecurser($xmlDataIterator);
     // contexts should be initialized after the unwinding of the profile structure
     $this->_lazyLoadContexts();
     return $this->_profile;
 }
開發者ID:CEMD-CN,項目名稱:MageTool,代碼行數:32,代碼來源:Xml.php

示例3: unserialize

 /**
  * unserialize()
  *
  * Create a structure in the object $profile from the structure specficied
  * in the xml string provided
  *
  * @param string xml data
  * @param Zend_Tool_Project_Profile The profile to use as the top node
  * @return Zend_Tool_Project_Profile
  */
 public function unserialize($data, Zend_Tool_Project_Profile $profile)
 {
     if ($data == null) {
         throw new Exception('contents not available to unserialize.');
     }
     $this->_profile = $profile;
     $xmlDataIterator = new SimpleXMLIterator($data);
     if ($xmlDataIterator->getName() != 'projectProfile') {
         throw new Exception('Profiles must start with a projectProfile node');
     }
     $this->_unserializeRecurser($xmlDataIterator);
     $this->_lazyLoadContexts();
     return $this->_profile;
 }
開發者ID:c12g,項目名稱:stratos-php,代碼行數:24,代碼來源:Xml.php

示例4: _unserializeXml

 protected function _unserializeXml($xmlProjectProfile)
 {
     if ($xmlProjectProfile == null) {
         throw new Exception('contents not available to unserialize.');
     }
     $projectProfileIterator = new SimpleXMLIterator($xmlProjectProfile);
     if ($projectProfileIterator->getName() != 'projectProfile') {
         throw new Exception('Profiles must start with a projectProfile node');
     }
     $this->_unserializeRecurser($projectProfileIterator);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:11,代碼來源:ProjectProfile.php

示例5: SimpleXMLIterator

<pre>
<?php 
$xml = <<<XML
<books>
    <book>
        <title>PHP Basics</title>
        <author>Jim Smith</author>
    </book>
    <book>XML basics</book>
</books>
XML;
$xmlIterator = new SimpleXMLIterator($xml);
//books
for ($xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next()) {
    foreach ($xmlIterator->getChildren() as $name => $data) {
        echo "The {$name} is '{$data}' from the class " . get_class($data) . "\n";
    }
    echo $xmlIterator->getName() . "\n";
    //2 times of books will be print out
}
?>
</pre>
開發者ID:pixlr,項目名稱:zce-1,代碼行數:22,代碼來源:getChildren.php

示例6: updateAPP

 protected function updateAPP()
 {
     if (is_file($this->applist) && is_writable($this->applist)) {
         try {
             $doc = new SimpleXMLIterator($this->applist, null, true);
         } catch (Exception $e) {
             $this->error[] = "發生異常:" . $e->getMessage() . "  文件:" . $e->getFile() . "  行號:" . $e->getLine();
             return false;
         }
         if ($doc->getName() != "apps") {
             $this->error[] = "applist.xml的根元素必須是apps";
             return false;
         }
         $i = $doc->count();
         if ($i !== 0) {
             $apps = $doc->app;
             foreach ($apps as $app) {
                 if ($app['name'] == $this->app_name) {
                     $this->error[] = "項目列表存在重名項目,請修改項目名稱";
                     return false;
                 }
             }
         }
         $doc->addChild("app");
         $doc->app[$i]->addAttribute("name", $this->app_name);
         $doc->app[$i]->addAttribute("path", $this->app_path);
         $doc->app[$i]->addAttribute("index", $this->app_index);
         if ($doc->asXML($this->applist)) {
             return true;
         } else {
             $this->error[] = "TinkPHP助手/data/applist.xml 寫入失敗";
             return false;
         }
     } else {
         $this->error[] = "TinkPHP助手/data/applist.xml不存在";
         return false;
     }
 }
開發者ID:sdgdsffdsfff,項目名稱:TPhelper,代碼行數:38,代碼來源:AdminAction.class.php

示例7: arrayFromXml

    /**
     * Create an Array from XML
     *
     * This method sets up the SimpleXMLIterator and starts the parsing
     * of an xml body to iterate through it and transform it into
     * an array that can be used by the developers.
     *
     * @param string $xml
     * @return array An array mapped to the passed xml
     */
    public static function arrayFromXml($xml)
    {
        // replace namespace defs
        $xml = str_replace('xmlns=', 'ns=', $xml);

        // catch libxml errors
        libxml_use_internal_errors(true);
        try {
            $iterator = new SimpleXMLIterator($xml);
        } catch(Exception $e) {
            $xmlErrors = libxml_get_errors();
             return new Frapi_Exception(
                     'Xml Parsing Failed', 
                     'INVALID_XML', 
                     400, 
                     'xml_parsing'
                     );
             libxml_clear_errors();
        }
        
        $xmlRoot = $iterator->getName();
        $type = $iterator->attributes()->type;

        // SimpleXML provides the root information on construct
        self::$_xmlRoot = $iterator->getName();
        self::$_responseType = $type;
        
        // return the mapped array with the root element as the header
        return array($xmlRoot => self::_iteratorToArray($iterator));
    }
開發者ID:reith2004,項目名稱:frapi,代碼行數:40,代碼來源:XmlParser.php

示例8: arrayFromXml

 /**
  * sets up the SimpleXMLIterator and starts the parsing
  * @access public
  * @param string $xml
  * @return array array mapped to the passed xml
  */
 public static function arrayFromXml($xml)
 {
     // SimpleXML provides the root information on construct
     $iterator = new SimpleXMLIterator($xml);
     $xmlRoot = Braintree_Util::delimiterToCamelCase($iterator->getName());
     $type = $iterator->attributes()->type;
     self::$_xmlRoot = $iterator->getName();
     self::$_responseType = $type;
     // return the mapped array with the root element as the header
     return array($xmlRoot => self::_iteratorToArray($iterator));
 }
開發者ID:danielcoats,項目名稱:schoolpress,代碼行數:17,代碼來源:Parser.php


注:本文中的SimpleXMLIterator::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。