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


PHP SimpleXMLElement::addAttribute方法代码示例

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


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

示例1: serialize

    /**
     * serialize()
     *
     * create an xml string from the provided profile
     *
     * @param Zend_Tool_Project_Profile $profile
     * @return string
     */
    public function serialize(Zend_Tool_Project_Profile $profile)
    {

        $profile = clone $profile;

        $this->_profile = $profile;
        $xmlElement = new SimpleXMLElement('<projectProfile />');

        if ($profile->hasAttribute('type')) {
            $xmlElement->addAttribute('type', $profile->getAttribute('type'));
        }

        if ($profile->hasAttribute('version')) {
            $xmlElement->addAttribute('version', $profile->getAttribute('version'));
        }

        self::_serializeRecurser($profile, $xmlElement);

        $doc = new DOMDocument('1.0');
        $doc->formatOutput = true;
        $domnode = dom_import_simplexml($xmlElement);
        $domnode = $doc->importNode($domnode, true);
        $domnode = $doc->appendChild($domnode);

        return $doc->saveXML();
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:34,代码来源:Xml.php

示例2: generateSiteMap

 public function generateSiteMap($sitemap = 'sitemap.xml', $siteURL = null)
 {
     $siteData = singleton('SiteDataService');
     $pages = $siteData->getItems();
     $xml = new SimpleXMLElement('<urlset></urlset>');
     $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     $xml->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd');
     if (!$siteURL) {
         $siteURL = self::config()->get('base_url');
         if (!$siteURL) {
             $siteURL = Director::absoluteBaseURL();
         }
     }
     $siteURL = rtrim($siteURL, '/') . '/';
     if (!strpos($siteURL, ':/')) {
         $siteURL = $this->config()->protocol . '://' . $siteURL;
     }
     foreach ($pages as $page) {
         $url = $xml->addChild('url');
         $url->addChild('loc', $siteURL . $page->Link);
         $url->addChild('changefreq', $page->ChangeFreq);
         $url->addChild('priority', $page->Priority);
     }
     file_put_contents($sitemap, $xml->asXML());
 }
开发者ID:Marketo,项目名称:SilverStripe-Performable-Sitemaps,代码行数:26,代码来源:SiteMapXMLController.php

示例3: index

 /**
  * Add item index and level to class attribute
  *
  * @param  SimpleXMLElement $node The node to add the index and level to
  * @param  array            $args Callback arguments
  */
 public static function index(SimpleXMLElement $node, $args)
 {
     if ($node->getName() == 'ul') {
         // set up level
         $level = $args['level'] / 2 + 1;
         if ($level > 1) {
             $node->addAttribute('class', 'uk-nav uk-nav-navbar');
         } else {
             $node->addAttribute('class', 'uk-navbar-nav');
         }
     }
     if ($node->getName() == 'li') {
         $css = '';
         // parent
         if (isset($node->div)) {
             $css .= ' uk-parent';
             $node->addAttribute('data-uk-dropdown', '');
         }
         // add li css classes
         $node->attributes()->class = trim($node->attributes()->class . $css);
         // add a/span css classes
         $children = $node->children();
         if ($firstChild = $children[0]) {
             $firstChild->addAttribute('class', trim($firstChild->attributes()->class . $css));
         }
     }
     unset($node->attributes()->icon);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:_zlmenu.php

示例4: addExtensionElement

 /**
  * Funkce pro přidání tagu <Extension name="..." value="..." />
  *
  * @param \SimpleXMLElement &$parentSimpleXmlElement
  * @param string $extensionName
  * @param string $extensionValue
  * @param string|null $extensionExtender
  */
 protected function addExtensionElement(\SimpleXMLElement &$parentSimpleXmlElement, $extensionName, $extensionValue, $extensionExtender = null, $groupExtensions = true)
 {
     if ($groupExtensions && count($parentSimpleXmlElement->Extension) > 0) {
         //TODO tohle nefunguje v rámci nového serveru...
         /** @noinspection PhpUndefinedFieldInspection */
         $siblinkElement = $parentSimpleXmlElement->Extension[0];
         $siblinkElementDom = dom_import_simplexml($siblinkElement);
         //připravení elementu pro připojení
         $extensionElement = new \SimpleXMLElement('<Extension />');
         $extensionElement->addAttribute('name', $extensionName);
         $extensionElement->addAttribute('value', $extensionValue);
         if ($extensionExtender !== null) {
             $extensionElement->addAttribute('extender', $extensionExtender);
         }
         $extensionElementDom = $siblinkElementDom->ownerDocument->importNode(dom_import_simplexml($extensionElement), true);
         $siblinkElementDom->parentNode->insertBefore($extensionElementDom, $siblinkElementDom);
     } else {
         $extensionElement = $parentSimpleXmlElement->addChild('Extension');
         $extensionElement->addAttribute('name', $extensionName);
         $extensionElement->addAttribute('value', $extensionValue);
         if ($extensionExtender !== null) {
             $extensionElement->addAttribute('extender', $extensionExtender);
         }
     }
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:33,代码来源:PmmlSerializerTrait.php

示例5: __construct

 /**
  * @param SmartHome $smartHome
  */
 public function __construct(SmartHome $smartHome)
 {
     $this->smartHome = $smartHome;
     $reflectionClass = new \ReflectionClass($this);
     $this->request = new \SimpleXMLElement('<BaseRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" />');
     $this->request->addAttribute('xsi:type', $reflectionClass->getShortName(), 'http://www.w3.org/2001/XMLSchema-instance');
 }
开发者ID:bendspoons,项目名称:SmartHome-PHP,代码行数:10,代码来源:BaseRequest.php

示例6: saveConfig

 /**
 * Save the setup data
 * @param array $dbconfig
 * @param array $preferences
 * 
 * <?xml version="1.0" encoding="UTF-8"?>
 		<shineisp>
 			<config>
 				<database>
 					<hostname>localhost</hostname>
 					<db>shineisp</db>
 					<username>shineisp</username>
 					<password>shineisp2013</password>
 				</database>
 			</config>
 		</shineisp>
 */
 public static function saveConfig($dbconfig, $version = null)
 {
     try {
         $xml = new SimpleXMLElement('<shineisp></shineisp>');
         if (!empty($version)) {
             $xml->addAttribute('version', $version);
         }
         $xml->addAttribute('setupdate', date('Ymdhis'));
         $config = $xml->addChild('config');
         // Database Configuration
         $database = $config->addChild('database');
         $database->addChild('hostname', $dbconfig->hostname);
         $database->addChild('username', $dbconfig->username);
         $database->addChild('password', $dbconfig->password);
         $database->addChild('database', $dbconfig->database);
         // Get the xml string
         $xmlstring = $xml->asXML();
         // Prettify and save the xml configuration
         $dom = new DOMDocument();
         $dom->loadXML($xmlstring);
         $dom->formatOutput = true;
         $dom->saveXML();
         // Save the config xml file
         if (@$dom->save(APPLICATION_PATH . "/configs/config.xml")) {
             Shineisp_Commons_Utilities::log("Update ShineISP config xml file");
             return true;
         } else {
             throw new Exception("Error on saving the xml file in " . APPLICATION_PATH . "/configs/config.xml <br/>Please check the folder permissions");
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return false;
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:51,代码来源:Settings.php

示例7: render

 public function render()
 {
     $root = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><response/>');
     $root->addAttribute("client", $_SERVER['REMOTE_ADDR']);
     $root->addAttribute("time", time());
     $this->_encode($this->rootElement, $this->_params, $root);
     echo $root->asXML();
 }
开发者ID:jenky,项目名称:serapia,代码行数:8,代码来源:Xml.php

示例8: asElement

 public function asElement()
 {
     $element = new \SimpleXMLElement('<payment/>');
     $element->addAttribute('method', $this->_method);
     $element->addAttribute('currency', $this->_currency);
     $element->addChild('amount', $this->_amount);
     return $element;
 }
开发者ID:mdiniz,项目名称:ratepay-php,代码行数:8,代码来源:Payment.php

示例9: _getResponse

 /**
  * getting the response
  * 
  * @param UDate $time
  * 
  * @return SimpleXMLElement
  */
 protected function _getResponse(UDate $time)
 {
     Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
     //TODO
     $response = new SimpleXMLElement('<Response />');
     $response->addAttribute('Time', trim($time));
     $response->addAttribute('TimeZone', trim($time->getTimeZone()->getName()));
     return $response;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:16,代码来源:APIClassAbstract.php

示例10: exportToXML

 /**
  * Transforms CannedResponse into a SimpleXMLElement
  * 
  * @param SimpleXMLElement $root the node to which the CannedResponse is attached (passed by reference)
  *
  * @return void
  */
 public function exportToXML($root)
 {
     // if old ids are important, modify code here
     if (false) {
         $root->addAttribute('id', $this->id);
         $root->addAttribute('tracker', $this->tracker->id);
     }
     $root->addChild('title', $this->title);
     $root->addChild('body', $this->body);
 }
开发者ID:nterray,项目名称:tuleap,代码行数:17,代码来源:Tracker_CannedResponse.class.php

示例11: testRender

 /**
  * @covers src\Element\TextField::render
  * @todo   Implement testRender().
  */
 public function testRender()
 {
     $html = $this->object->render();
     $this->assertInstanceOf('\\SimpleXMLElement', simplexml_load_string($html));
     $xmlElement = new \SimpleXMLElement('<input/>');
     $xmlElement->addAttribute('id', 'textField');
     $xmlElement->addAttribute('value', 'value');
     $xmlElement->addAttribute('type', 'text');
     $this->assertEquals($xmlElement, simplexml_load_string($html));
 }
开发者ID:vladis84,项目名称:SimpleForm,代码行数:14,代码来源:TextFieldTest.php

示例12: setBaseXml

 /**
  * define base xml tree
  *
  * return void
  */
 protected function setBaseXml()
 {
     $this->baseXml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset/>');
     $this->baseXml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach ($this->spaces as $space => $schema) {
         if ($this->isType($space)) {
             $this->baseXml->addAttribute('xmlns:xmlns:' . $space, $schema);
         }
     }
 }
开发者ID:b2un0,项目名称:joomla-component-mapx,代码行数:15,代码来源:xml.php

示例13: setGeneralInfo

 /**
  * Set general info
  */
 protected function setGeneralInfo()
 {
     if (strlen(SessionAccountHandler::getName()) > 0) {
         $this->XML->AthleteLog->Athlete->addAttribute('Name', SessionAccountHandler::getName());
     }
     $this->Activity->addAttribute('StartTime', $this->timeToString($this->Context->activity()->timestamp()));
     $this->Activity->Duration->addAttribute('TotalSeconds', (int) $this->Context->activity()->duration());
     $this->Activity->Distance->addAttribute('TotalMeters', 1000 * $this->Context->activity()->distance());
     $this->Activity->Calories->addAttribute('TotalCal', $this->Context->activity()->calories());
 }
开发者ID:aschix,项目名称:Runalyze,代码行数:13,代码来源:Fitlog.php

示例14: getMrssXml

 /**
  * @param string $title
  * @param string $link
  * @param string $description
  * @return SimpleXMLElement
  */
 public static function getMrssXml($title, $link = null, $description = null)
 {
     $mrss = new SimpleXMLElement('<rss/>');
     $mrss->addAttribute('version', '2.0');
     $mrss->addAttribute('xmlns:content', 'http://www.w3.org/2001/XMLSchema-instance');
     $channel = $mrss->addChild('channel');
     $channel->addChild('title', self::stringToSafeXml($title));
     $channel->addChild('link', $link);
     $channel->addChild('description', self::stringToSafeXml($description));
     return $mrss;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:17,代码来源:kMrssManager.php

示例15: toXml

 /**
  * {@inheritDoc}
  */
 public function toXml(\SimpleXMLElement $parent = null)
 {
     if (null !== $parent) {
         $xml = $parent->addChild('Station');
     } else {
         $xml = new \SimpleXMLElement('<Station />');
     }
     $xml->addAttribute('name', $this->name);
     $xml->addAttribute('externalId', $this->id);
     return $xml;
 }
开发者ID:BJDev95,项目名称:Transport,代码行数:14,代码来源:Station.php


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