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


PHP DOMDocument::createElement方法代码示例

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


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

示例1: serialize

 /**
  * (non-PHPdoc)
  * @see lib/Faett/Channel/Serializer/Interfaces/Faett_Channel_Serializer_Interfaces_Serializer#serialize()
  */
 public function serialize()
 {
     try {
         // initialize a new DOM document
         $doc = new DOMDocument('1.0', 'UTF-8');
         // create new namespaced root element
         $a = $doc->createElementNS($this->_namespace, 'a');
         // add the schema to the root element
         $a->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd');
         // create an element for the channel's name
         $ch = $doc->createElement('ch');
         $ch->nodeValue = Mage::helper('channel')->getChannelName();
         // append the element with the channel's name to the root element
         $a->appendChild($ch);
         // load the product's attributes
         $attributes = $this->_category->getSelectOptions();
         // iterate over the channel's categories
         foreach ($attributes as $attribute) {
             $c = $doc->createElement('c');
             $c->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '/channel/index/c/' . $attribute . '/info.xml');
             $c->nodeValue = $attribute;
             // append the XLink to the root element
             $a->appendChild($c);
         }
         // append the root element to the DOM tree
         $doc->appendChild($a);
         // return the XML document
         return $doc->saveXML();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:BGCX067,项目名称:faett-channel-svn-to-git,代码行数:36,代码来源:Categories.php

示例2: getMessage

 /**
  *
  * @return string
  */
 public function getMessage()
 {
     if (empty($this->_jobTraining)) {
         return '';
     }
     $this->_dom = new DOMDocument();
     $classMessage = 'alert ';
     $divFluid = $this->_dom->createElement('div');
     $divMessage = $this->_dom->createElement('div');
     $divFluid->setAttribute('class', 'row-fluid');
     if ($this->_jobTraining->status != 1) {
         $classMessage .= 'alert-error';
         $iconClass = 'icon-remove-sign';
         $alertText = ' Atensaun ';
         $message = ' Job Training ' . ($this->_jobTraining->status == 2 ? 'Kansela' : 'Taka') . ' tiha ona, La bele halo Atualizasaun.';
     } else {
         $iconClass = 'icon-ok-sign';
         $classMessage .= 'alert-success';
         $alertText = '';
         $message = ' Job Training Loke, então bele halo Atualizasaun.';
     }
     $divMessage->setAttribute('class', $classMessage);
     $strong = $this->_dom->createElement('strong');
     $i = $this->_dom->createElement('i');
     $i->setAttribute('class', $iconClass);
     $strong->appendChild($i);
     $strong->appendChild($this->_dom->createTextNode($alertText));
     $divMessage->appendChild($strong);
     $divMessage->appendChild($this->_dom->createTextNode($message));
     $divFluid->appendChild($divMessage);
     $this->_dom->appendChild($divFluid);
     return $this->_dom->saveHTML();
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:37,代码来源:JobTrainingActive.php

示例3: load

 /**
  * Load DOMDocument from xml string
  *
  * @param string $source xml string
  * @param string $contentType
  * @return DOMDocument|FALSE
  */
 public function load($source, $contentType)
 {
     if (is_object($source) && $source instanceof PDOStatement) {
         $source->setFetchMode(PDO::FETCH_NUM);
         $columnCount = $source->columnCount();
         $columns = array();
         for ($i = 0; $i < $columnCount; $i++) {
             $columnData = $source->getColumnMeta($i);
             $columns[$i] = array('name' => $this->_normalizeColumnName($columnData['name']), 'type' => $this->_getNodeType($columnData));
         }
         $dom = new DOMDocument();
         $dom->formatOutput = TRUE;
         $dom->appendChild($rootNode = $dom->createElement($this->_tagNameRoot));
         foreach ($source as $row) {
             $rootNode->appendChild($recordNode = $dom->createElement($this->_tagNameRecord));
             foreach ($row as $columnId => $value) {
                 switch ($columns[$columnId]['type']) {
                     case self::ATTRIBUTE_VALUE:
                         $recordNode->setAttribute($columns[$columnId]['name'], $value);
                         break;
                     default:
                         $recordNode->appendChild($valueNode = $dom->createElement($columns[$columnId]['name'], $value));
                         break;
                 }
             }
         }
         return $dom;
     }
     return FALSE;
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:37,代码来源:PDO.php

示例4: describeAnalysis

 protected function describeAnalysis(Analysis $analysis, array $options = array())
 {
     $output = $options['output'];
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xpath = new \DOMXPath($xml);
     $xml->formatOutput = true;
     $xml->preserveWhiteSpace = true;
     $pmd = $xml->createElement('pmd');
     $pmd->setAttribute('timestamp', $analysis->getEndAt()->format('c'));
     $xml->appendChild($pmd);
     foreach ($analysis->getViolations() as $violation) {
         /**
          * @var $violation \SensioLabs\Insight\Sdk\Model\Violation
          */
         $filename = $violation->getResource();
         $nodes = $xpath->query(sprintf('//file[@name="%s"]', $filename));
         if ($nodes->length > 0) {
             $node = $nodes->item(0);
         } else {
             $node = $xml->createElement('file');
             $node->setAttribute('name', $filename);
             $pmd->appendChild($node);
         }
         $violationNode = $xml->createElement('violation', $violation->getMessage());
         $node->appendChild($violationNode);
         $violationNode->setAttribute('beginline', $violation->getLine());
         $violationNode->setAttribute('endline', $violation->getLine());
         $violationNode->setAttribute('rule', $violation->getTitle());
         $violationNode->setAttribute('ruleset', $violation->getCategory());
         $violationNode->setAttribute('priority', $this->getPriority($violation));
     }
     $output->writeln($xml->saveXML());
 }
开发者ID:ftdysa,项目名称:insight,代码行数:33,代码来源:PmdDescriptor.php

示例5: __call

 public function __call($method, $arguments)
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->createElement('method');
     $element->setAttribute('name', $method);
     foreach ($arguments as $argument) {
         $child = $dom->createElement('argument');
         $textNode = $dom->createTextNode($argument);
         $child->appendChild($textNode);
         $element->appendChild($child);
     }
     $dom->appendChild($element);
     $data = 'service=' . $dom->saveXML();
     $params = array('http' => array('method' => 'POST', 'content' => $data));
     $ctx = stream_context_create($params);
     $fp = @fopen($this->server, 'rb', false, $ctx);
     if (!$fp) {
         throw new Exception('Problem with URL');
     }
     $response = @stream_get_contents($fp);
     if ($response === false) {
         throw new Exception("Problem reading data from {$this->server}");
     }
     $dom = new DOMDocument(null, 'UTF-8');
     $dom->loadXML($response);
     $result = $dom->childNodes->item(0)->childNodes->item(0)->nodeValue;
     $type = $dom->childNodes->item(0)->childNodes->item(1)->nodeValue;
     settype($result, $type);
     return $result;
 }
开发者ID:pelif,项目名称:studyWS,代码行数:30,代码来源:WebServiceClientProxy.php

示例6: getAsElem

 /**
  * Get the constraint as a DOMElement object.
  *
  * @param DOMDocument $dom The DOMDocument object with which to create the element.
  */
 public function getAsElem($dom)
 {
     $constElem = $dom->createElement('constraint');
     $constElem->setAttribute('name', $this->name);
     $valElem = $dom->createElement('value');
     $elemElem = $dom->createElement('element');
     $elemElem->setAttribute('ns', $this->ns);
     $elemElem->setAttribute('name', $this->elem);
     $valElem->appendChild($elemElem);
     if ($this->attr) {
         $attrElem = $dom->createElement('attribute');
         $attrElem->setAttribute('ns', $this->attrNs);
         $attrElem->setAttribute('name', $this->attr);
         $valElem->appendChild($attrElem);
     }
     $this->addTermOptions($dom, $valElem);
     $this->addFragmentScope($dom, $valElem);
     $constElem->appendChild($valElem);
     /* <constraint name='flavor'>
         <value>
             <element ns='http://example.com' name='flavor-descriptor'/>
         </value>
        </constraint> */
     return $constElem;
 }
开发者ID:marklogic,项目名称:mlphp,代码行数:30,代码来源:ValueConstraint.php

示例7: setChild

 /**
  * Sets a child on the given DOMDocument
  * Returns true if a child was set, false if not
  *
  * @param \DOMElement $xml
  * @param mixed       $value
  * @param string      $variable
  * @param array       $options
  *
  * @return boolean
  */
 protected function setChild(\DOMElement $xml, $value, $variable, $options)
 {
     if (null === $value) {
         return false;
     }
     switch ($options['type']) {
         case 'string':
         case 'integer':
             $element = $this->dom->createElement($variable, $value);
             break;
         case 'boolean':
             $element = $this->dom->createElement($variable, $this->visitBoolean($value));
             break;
         case 'datetime':
             $element = $this->dom->createElement($variable, $this->visitDatetime($value));
             break;
         default:
             if (class_exists($options['type'])) {
                 // We mapped to an existing class
                 $element = $this->visitModel($value);
             } elseif ($this->isArrayType($options['type'], $arrayType, $keepKey)) {
                 // We mapped to an array<type>
                 $element = $this->dom->createElement($variable);
                 foreach ($value as $key => $val) {
                     $key = $keepKey ? $key : $options['key'];
                     $this->setChild($element, $val, $key, ['type' => $arrayType]);
                 }
             } else {
                 // A type we can't handle
                 return false;
             }
     }
     $xml->appendChild($element);
     return true;
 }
开发者ID:moovly,项目名称:recurly,代码行数:46,代码来源:SerializeVisitor.php

示例8: _future_serializeAsXml

 /**
  * @author Zack Douglas <zack@zackerydouglas.info>
  */
 private function _future_serializeAsXml($value, $node = null, $dom = null)
 {
     if (!$dom) {
         $dom = new \DOMDocument();
     }
     if (!$node) {
         if (!is_object($value)) {
             $node = $dom->createElement('response');
             $dom->appendChild($node);
         } else {
             $node = $dom;
         }
     }
     if (is_object($value)) {
         $objNode = $dom->createElement(get_class($value));
         $node->appendChild($objNode);
         $this->_future_serializeObjectAsXml($value, $objNode, $dom);
     } else {
         if (is_array($value)) {
             $arrNode = $dom->createElement('array');
             $node->appendChild($arrNode);
             $this->_future_serializeArrayAsXml($value, $arrNode, $dom);
         } else {
             if (is_bool($value)) {
                 $node->appendChild($dom->createTextNode($value ? 'TRUE' : 'FALSE'));
             } else {
                 $node->appendChild($dom->createTextNode($value));
             }
         }
     }
     return array($node, $dom);
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:35,代码来源:XmlHandler.php

示例9: action_index

 public function action_index()
 {
     if (!file_exists(DOCROOT . $this->sitemap_directory_base)) {
         throw new HTTP_Exception_404();
     }
     $this->site_code = ORM::factory('site', $this->request->site_id)->code;
     $this->sitemap_directory = $this->sitemap_directory_base . DIRECTORY_SEPARATOR . $this->site_code;
     $this->response->headers('Content-Type', 'text/xml')->headers('cache-control', 'max-age=0, must-revalidate, public')->headers('expires', gmdate('D, d M Y H:i:s', time()) . ' GMT');
     try {
         $dir = new DirectoryIterator(DOCROOT . $this->sitemap_directory);
         $xml = new DOMDocument('1.0', Kohana::$charset);
         $xml->formatOutput = TRUE;
         $root = $xml->createElement('sitemapindex');
         $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
         $xml->appendChild($root);
         foreach ($dir as $fileinfo) {
             if ($fileinfo->isDot() or $fileinfo->isDir()) {
                 continue;
             }
             $_file_path = str_replace(DOCROOT, '', $fileinfo->getPathName());
             $_file_url = $this->domain . '/' . str_replace(DIRECTORY_SEPARATOR, '/', $_file_path);
             $sitemap = $xml->createElement('sitemap');
             $root->appendChild($sitemap);
             $sitemap->appendChild(new DOMElement('loc', $_file_url));
             $_last_mod = Sitemap::date_format($fileinfo->getCTime());
             $sitemap->appendChild(new DOMElement('lastmod', $_last_mod));
         }
     } catch (Exception $e) {
         echo Debug::vars($e->getMessage());
         die;
     }
     echo $xml->saveXML();
 }
开发者ID:greor,项目名称:satin-spb,代码行数:33,代码来源:sitemap.php

示例10: _buildTransaction

 private function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null)
 {
     $amount = HpsInputValidation::checkAmount($amount);
     if ($check->secCode == HpsSECCode::CCD && ($check->checkHolder == null || $check->checkHolder->checkName == null)) {
         throw new HpsInvalidRequestException(HpsExceptionCodes::MISSING_CHECK_NAME, 'For SEC code CCD, the check name is required', 'check_name');
     }
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCheckSale = $xml->createElement('hps:CheckSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
     $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
     $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
     $hpsBlock1->appendChild($xml->createElement('hps:SECCode', $check->secCode));
     if ($check->checkType != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType));
     }
     $hpsBlock1->appendChild($xml->createElement('hps:DataEntryMode', $check->dataEntryMode));
     if ($check->checkHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateConsumerInfo($check, $xml));
     }
     $hpsCheckSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCheckSale);
     return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
 }
开发者ID:ChessMess,项目名称:heartland-gravity-forms-addon,代码行数:25,代码来源:HpsCheckService.php

示例11: get

 static function get($jid, $start = false, $end = false, $limit = false)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $query = $dom->createElementNS('urn:xmpp:mam:0', 'query');
     $x = $dom->createElementNS('jabber:x:data', 'x');
     $query->appendChild($x);
     $field_type = $dom->createElement('field');
     $field_type->setAttribute('var', 'FORM_TYPE');
     $field_type->appendChild($dom->createElement('value', 'urn:xmpp:mam:0'));
     $x->appendChild($field_type);
     $field_with = $dom->createElement('field');
     $field_with->setAttribute('var', 'with');
     $field_with->appendChild($dom->createElement('value', $jid));
     $x->appendChild($field_with);
     if ($start) {
         $field_start = $dom->createElement('field');
         $field_start->setAttribute('var', 'start');
         $field_start->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $start + 1)));
         $x->appendChild($field_start);
     }
     if ($end) {
         $field_end = $dom->createElement('field');
         $field_end->setAttribute('var', 'end');
         $field_end->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $end + 1)));
         $x->appendChild($field_end);
     }
     if ($limit) {
         $field_limit = $dom->createElement('field');
         $field_limit->setAttribute('var', 'limit');
         $field_limit->appendChild($dom->createElement($limit));
         $x->appendChild($field_limit);
     }
     $xml = \Moxl\API::iqWrapper($query, null, 'set');
     \Moxl\API::request($xml);
 }
开发者ID:Hywan,项目名称:moxl,代码行数:35,代码来源:MAM.php

示例12: createXmlElement

 public function createXmlElement(DOMDocument $xmlDoc)
 {
     if (!$xmlDoc instanceof DOMDocument) {
         throw new Exception('', self::ERROR_INVALID_PARAMETER);
     }
     $xmlItemElem = $xmlDoc->createElement('item');
     if ($this->code == null || $this->name == null || $this->measurment == null || $this->quantity == null || $this->price == null || $this->vat == null) {
         throw new Exception('Invalid property', self::ERROR_INVALID_PROPERTY);
     }
     $xmlElem = $xmlDoc->createElement('code');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->code)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('name');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->name)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('measurment');
     $xmlElem->appendChild($xmlDoc->createCDATASection(urlencode($this->measurment)));
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('quantity');
     $xmlElem->nodeValue = $this->quantity;
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('price');
     $xmlElem->nodeValue = $this->price;
     $xmlItemElem->appendChild($xmlElem);
     $xmlElem = $xmlDoc->createElement('vat');
     $xmlElem->nodeValue = $this->vat;
     $xmlItemElem->appendChild($xmlElem);
     return $xmlItemElem;
 }
开发者ID:bardascat,项目名称:blogify,代码行数:29,代码来源:Item.php

示例13: render

 public function render($caption_set, $file = false)
 {
     $dom = new \DOMDocument("1.0");
     $dom->formatOutput = true;
     $root = $dom->createElement('tt');
     $dom->appendChild($root);
     $body = $dom->createElement('body');
     $root->appendChild($body);
     $xmlns = $dom->createAttribute('xmlns');
     $xmlns->appendChild($dom->createTextNode('http://www.w3.org/ns/ttml'));
     $root->appendChild($xmlns);
     $div = $dom->createElement('div');
     $body->appendChild($div);
     foreach ($caption_set->captions() as $index => $caption) {
         $entry = $dom->createElement('p');
         $from = $dom->createAttribute('begin');
         $from->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->start())));
         $entry->appendChild($from);
         $to = $dom->createAttribute('end');
         $to->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->end())));
         $entry->appendChild($to);
         $entry->appendChild($dom->createCDATASection($caption->text()));
         $div->appendChild($entry);
     }
     if ($file) {
         return file_put_contents($file, $dom->saveXML());
     } else {
         return $dom->saveHTML();
     }
 }
开发者ID:ske,项目名称:captions-php,代码行数:30,代码来源:DfxpRenderer.php

示例14: unequalObjectsProvider

 public function unequalObjectsProvider()
 {
     $dom = new \DOMDocument();
     $element1 = $dom->createElement('foo', 'bar');
     $element2 = $dom->createElement('foo', 'baz');
     return array(array(new \StdClass(), new TestClass()), array(new TestClass('foo'), new TestClass('bar')), array(new TestClass(new \StdClass()), new TestClass(new TestClass())), array(new TestClass(new TestClass('foo')), new TestClass(new TestClass('bar'))), array(new TestClass($element1), new TestClass($element2)));
 }
开发者ID:belanur,项目名称:mokka,代码行数:7,代码来源:ObjectComparatorTest.php

示例15: createRss

 function createRss()
 {
     $dom = new DOMDocument("1.0", "utf-8");
     $dom->formatOutput = true;
     $dom->preserveWhiteSpace = false;
     $rss = $dom->createElement("rss");
     $dom->appendChild($rss);
     $version = $dom->createAttribute("version");
     $version->value = '2.0';
     $rss->appendChild($version);
     $channel = $dom->createElement("channel");
     $rss->appendChild($channel);
     $title = $dom->createElement("title", self::RSS_TITLE);
     $channel->appendChild($title);
     $link = $dom->createElement("link", self::RSS_LINK);
     $channel->appendChild($link);
     $items = $this->getNews();
     foreach ($items as $item) {
         $rssItem = $dom->createElement("item");
         $nTitle = $dom->createElement("title", $item["title"]);
         $nLink = $dom->createElement("link", $item["source"]);
         $nDesc = $dom->createElement("description", $item["description"]);
         $nPub = $dom->createElement("pubYear", $item["datetime"]);
         $nCategory = $dom->createElement("category", $item["category"]);
         $rssItem->appendChild($nTitle);
         $rssItem->appendChild($nLink);
         $rssItem->appendChild($nDesc);
         $rssItem->appendChild($nPub);
         $rssItem->appendChild($nCategory);
         $channel->appendChild($rssItem);
     }
     $dom->save(self::RSS_NAME);
 }
开发者ID:kapsilon,项目名称:Specialist,代码行数:33,代码来源:NewsDB.class.php


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