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


PHP XmlWriter::writeAttribute方法代碼示例

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


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

示例1: addHeader

 public function addHeader($type, $hasFeeds = false)
 {
     $this->writer->startElement($type);
     $this->writer->writeAttribute('xmlns', "http://www.sitemaps.org/schemas/sitemap/0.9");
     if ($hasFeeds) {
         $this->writer->writeAttribute('xmlns:image', "http://www.google.com/schemas/sitemap-image/1.1");
         $this->writer->writeAttribute('xmlns:video', "http://www.google.com/schemas/sitemap-video/1.1");
     }
     $this->writer->endAttribute();
     $this->openElements++;
     return $this;
 }
開發者ID:JoshBour,項目名稱:karolina,代碼行數:12,代碼來源:SitemapXmlParser.php

示例2: writeChannel

 /**
  * writeChannel writes a Core\Channel instance feed.
  *
  * @param Channel $channel
  *
  * @return mixed Similar to XMLWriter::flush 
  *
  * @see http://php.net/manual/function.xmlwriter-flush.php
  */
 public function writeChannel(Channel $channel)
 {
     $this->xmlWriter->startDocument();
     if ($this->flushEarly) {
         $this->xmlWriter->flush();
     }
     $this->xmlWriter->startElement('rss');
     foreach ($this->namespaces as $ns => $url) {
         $this->xmlWriter->writeAttribute(sprintf('xmlns:%s', $ns), $url);
     }
     $this->xmlWriter->writeAttribute('version', '2.0');
     $this->writeObject($channel);
     $this->xmlWriter->endElement();
     return $this->xmlWriter->flush();
 }
開發者ID:marcw,項目名稱:rss-writer,代碼行數:24,代碼來源:RssWriter.php

示例3: writeAttribute

 public function writeAttribute($name, $value, $prefix = null, $url = null)
 {
     if ($prefix !== null) {
         $this->cursor->writeAttributeNs($prefix, $name, $url, $value);
     } else {
         $this->cursor->writeAttribute($name, $value);
     }
 }
開發者ID:GromNaN,項目名稱:oxm,代碼行數:8,代碼來源:WriterHelper.php

示例4: output_xml

 public static function output_xml($data, $version = '0.1', $root = 'root', $parameters = array(), $sItemName = 'item')
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement($root);
     $xml->setIndent(true);
     if (!empty($version)) {
         $xml->writeAttribute('version', $version);
     }
     foreach ($parameters as $paramk => $paramv) {
         $xml->writeAttribute($paramk, $paramv);
     }
     self::writexml($xml, $data, $sItemName);
     $xml->endElement();
     return $xml->outputMemory(true);
 }
開發者ID:catlabinteractive,項目名稱:neuron,代碼行數:17,代碼來源:XML.php

示例5: outputXml

 function outputXml($results, $xsltPath)
 {
     /* Setting XML header */
     @header("content-type: text/xml; charset=UTF-8");
     /* Initializing the XML Object */
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('    ');
     $xml->startDocument('1.0', 'UTF-8');
     if (isset($xsltPath)) {
         $xml->WritePi('xml-stylesheet', 'type="text/xsl" href="' . $xsltPath . '"');
     }
     $xml->startElement('callback');
     $xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->writeAttribute('xsi:noNamespaceSchemaLocation', 'schema.xsd');
     /* Function that converts each array element to an XML node */
     function write(XMLWriter $xml, $data)
     {
         foreach ($data as $key => $value) {
             if (is_array($value)) {
                 if (is_numeric($key)) {
                     #The only time a numeric key would be used is if it labels an array with non-uniqe keys
                     write($xml, $value);
                     continue;
                 } else {
                     $xml->startElement($key);
                     write($xml, $value);
                     $xml->endElement();
                     continue;
                 }
             }
             $xml->writeElement($key, $value);
         }
     }
     /* Calls previously declared function, passing our results array as parameter */
     write($xml, $results);
     /* Closing last XML node */
     $xml->endElement();
     /* Printing the XML */
     echo $xml->outputMemory(true);
 }
開發者ID:Abbe98,項目名稱:ODOK,代碼行數:42,代碼來源:Format.php

示例6: executeXml

 public function executeXml(AgaviRequestDataHolder $request_data)
 {
     $report = $this->prepareReport($request_data);
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('application');
     $xml->writeAttribute('name', $report['application']);
     $xml->startElement('status');
     $xml->text($report['status']);
     $xml->endElement();
     $connections = $report['connections'];
     $xml->startElement('connections');
     foreach ($connections['stats'] as $name => $value) {
         $xml->writeAttribute($name, $value);
     }
     $xml->writeElement('status', $connections['status']);
     $xml->startElement('stats');
     foreach ($connections['stats'] as $name => $value) {
         $xml->writeElement($name, $value);
     }
     $xml->endElement();
     // connections/stats
     foreach ($connections['details'] as $name => $value) {
         $xml->startElement('connection');
         $xml->writeAttribute('name', $name);
         if (is_array($value)) {
             $this->array2xml($value, $xml);
         } else {
             $xml->writeCData((string) $value);
         }
         $xml->endElement();
     }
     $xml->endElement();
     // connections
     $xml->endElement();
     // application
     $xml->endDocument();
     return $xml->outputMemory();
 }
開發者ID:honeybee,項目名稱:honeybee-agavi-cmf-vendor,代碼行數:41,代碼來源:StatusSuccessView.class.php

示例7: toXml

 public function toXml(XmlWriter $x)
 {
     $x->startElement('template');
     $x->text($this->_template);
     $x->endElement();
     $x->startElement('params');
     foreach ($this->getVars() as $k => $v) {
         $x->startElement('param');
         $x->writeAttribute('name', $k);
         $x->text($v);
         $x->endElement();
     }
     $x->endElement();
 }
開發者ID:subashemphasize,項目名稱:test_site,代碼行數:14,代碼來源:HtmlTemplate.php

示例8: toXml

 function toXml(XmlWriter $x, $writeEnvelope = true)
 {
     if ($writeEnvelope) {
         $x->startElement('http-request');
     }
     $x->startElement('method');
     $x->text($this->getMethod());
     $x->endElement();
     $x->startElement('url');
     $x->text($this->getUrl());
     $x->endElement();
     $x->startElement('headers');
     foreach ($this->getHeaders() as $k => $v) {
         $x->startElement('header');
         $x->writeAttribute('name', $k);
         $x->text($v);
         $x->endElement();
     }
     $x->endElement();
     $x->startElement('params');
     foreach ($this->getPostParams() as $k => $v) {
         $x->startElement('param');
         $x->writeAttribute('name', $k);
         $x->text($v);
         $x->endElement();
     }
     $x->endElement();
     if (!$this->getPostParams() && $this->getBody()) {
         $x->startElement('body');
         $x->writeCdata($this->getBody());
         $x->endElement();
     }
     if ($writeEnvelope) {
         $x->endElement();
     }
 }
開發者ID:irovast,項目名稱:eyedock,代碼行數:36,代碼來源:HttpRequest.php

示例9: outputSitemap

 public function outputSitemap(Kwf_Component_Data $page)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach (array_unique($this->_getSitemap($page)) as $url) {
         $xml->startElement('url');
         $xml->writeElement('loc', $url);
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     header('Content-Type: text/xml; charset=utf-8');
     echo $xml->outputMemory(true);
     exit;
 }
開發者ID:nsams,項目名稱:koala-framework,代碼行數:18,代碼來源:Sitemap.php

示例10: createUpdates

 /**
  * Create document(s) update XML
  *
  * @param array $documents
  *
  * @return string
  */
 protected function createUpdates(array $documents)
 {
     $xml = new \XmlWriter();
     $xml->openMemory();
     $xml->startElement('add');
     foreach ($documents as $document) {
         $xml->startElement('doc');
         foreach ($document as $field) {
             foreach ((array) $this->fieldValueMapper->map($field) as $value) {
                 $xml->startElement('field');
                 $xml->writeAttribute('name', $this->nameGenerator->getTypedName($field->name, $field->type));
                 $xml->text($value);
                 $xml->endElement();
             }
         }
         $xml->endElement();
     }
     $xml->endElement();
     return $xml->outputMemory(true);
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:27,代碼來源:Native.php

示例11: objectSerialize

 /** 
  * Serialize an object with specified root element name. 
  * 
  * @param object $targetObject The target object. 
  * @param string $rootName     The name of the root element. 
  * 
  * @return string
  */
 public static function objectSerialize($targetObject, $rootName)
 {
     Validate::notNull($targetObject, 'targetObject');
     Validate::isString($rootName, 'rootName');
     $xmlWriter = new \XmlWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $reflectionClass = new \ReflectionClass($targetObject);
     $methodArray = $reflectionClass->getMethods();
     $attributes = self::_getInstanceAttributes($targetObject, $methodArray);
     $xmlWriter->startElement($rootName);
     if (!is_null($attributes)) {
         foreach (array_keys($attributes) as $attributeKey) {
             $xmlWriter->writeAttribute($attributeKey, $attributes[$attributeKey]);
         }
     }
     foreach ($methodArray as $method) {
         if (strpos($method->name, 'get') === 0 && $method->isPublic() && $method->name != 'getAttributes') {
             $variableName = substr($method->name, 3);
             $variableValue = $method->invoke($targetObject);
             if (!empty($variableValue)) {
                 if (gettype($variableValue) === 'object') {
                     $xmlWriter->writeRaw(XmlSerializer::objectSerialize($variableValue, $variableName));
                 } else {
                     $xmlWriter->writeElement($variableName, $variableValue);
                 }
             }
         }
     }
     $xmlWriter->endElement();
     return $xmlWriter->outputMemory(true);
 }
開發者ID:bitmovin,項目名稱:azure-sdk-for-php,代碼行數:40,代碼來源:XmlSerializer.php

示例12: toXml

 function toXml(XmlWriter $x)
 {
     $x->startElement('url');
     $x->startElement('method');
     $x->text($this->getMethod());
     $x->endElement();
     $x->startElement('scheme');
     $x->text($this->getScheme());
     $x->endElement();
     $x->startElement('base_url');
     $x->text($this->getBaseUrl(true));
     $x->endElement();
     $x->startElement('path_info');
     $x->text($this->getPathInfo());
     $x->endElement();
     $x->startElement('host');
     $x->text($this->getHttpHost());
     $x->endElement();
     $x->startElement('remote_addr');
     $x->text($this->getClientIp(false));
     $x->endElement();
     $x->endElement();
     $x->startElement('params');
     foreach ($this->getRequestOnlyParams() as $k => $v) {
         $x->startElement('param');
         $x->writeAttribute('name', $k);
         if (is_array($v) || is_object($v)) {
             $v = json_encode($v);
             $x->writeAttribute("serialized", "json");
             $x->writeCdata($v);
         } else {
             $x->text($v);
         }
         $x->endElement();
     }
     $x->endElement();
 }
開發者ID:subashemphasize,項目名稱:test_site,代碼行數:37,代碼來源:Request.php

示例13: _serializeAtom

 /**
  * Serializes the atom into XML representation.
  * 
  * @param array $properties The atom properties.
  * 
  * @return string
  */
 private function _serializeAtom($properties)
 {
     $xmlw = new \XmlWriter();
     $xmlw->openMemory();
     $xmlw->setIndent(true);
     $xmlw->startDocument(strtoupper($this->_xmlVersion), $this->_xmlEncoding, 'yes');
     $xmlw->startElementNS(null, 'entry', $this->_atomNamespaceName);
     $xmlw->writeAttribute("xmlns:{$this->_dataServicesPrefix}", $this->_dataServicesNamespaceName);
     $xmlw->writeAttribute("xmlns:{$this->_dataServicesMetadataPrefix}", $this->_dataServicesMetadataNamespaceName);
     $xmlw->writeElement('title');
     $xmlw->writeElement('updated', Utilities::isoDate());
     $xmlw->startElement('author');
     $xmlw->writeElement('name');
     $xmlw->endElement();
     $xmlw->writeElement('id');
     $xmlw->startElement('content');
     $xmlw->writeAttribute('type', Resources::XML_CONTENT_TYPE);
     $xmlw->startElementNS($this->_dataServicesMetadataPrefix, 'properties', null);
     $this->_generateProperties($xmlw, $properties);
     $xmlw->endElement();
     $xmlw->endElement();
     $xmlw->endElement();
     return $xmlw->outputMemory(true);
 }
開發者ID:bitmovin,項目名稱:azure-sdk-for-php,代碼行數:31,代碼來源:AtomReaderWriter.php

示例14: Obj2XML

 public static function Obj2XML($obj)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(TRUE);
     $xml->startElement(get_class($obj));
     $xml->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
     $xml->writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
     self::getObject2XML($xml, $obj);
     $xml->endElement();
     $xml->endElement();
     return $xml->outputMemory(true);
 }
開發者ID:helpfulrobot,項目名稱:internetrix-silverstripe-payment-eway,代碼行數:13,代碼來源:Rapid3.0.php

示例15: index

 /**
  * Indexes the document $document using definition $definition
  *
  * @param ezcSearchDocumentDefinition $definition
  * @param mixed $document
  */
 public function index(ezcSearchDocumentDefinition $definition, $document)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startElement('add');
     $xml->startElement('doc');
     $xml->startElement('field');
     $xml->writeAttribute('name', 'ezcsearch_type_s');
     $xml->text($definition->documentType);
     $xml->endElement();
     $xml->startElement('field');
     $xml->writeAttribute('name', 'id');
     $xml->text($document[$definition->idProperty]);
     $xml->endElement();
     foreach ($definition->fields as $field) {
         $value = $this->mapFieldValuesForIndex($field, $document[$field->field]);
         foreach ($value as $fieldValue) {
             $xml->startElement('field');
             $xml->writeAttribute('name', $this->mapFieldType($field->field, $field->type));
             $xml->text($fieldValue);
             $xml->endElement();
         }
     }
     $xml->endElement();
     $xml->endElement();
     $doc = $xml->outputMemory(true);
     $r = $this->sendRawPostCommand('update', array('wt' => 'json'), $doc);
     if ($this->inTransaction == 0) {
         $this->runCommit();
     }
 }
開發者ID:zetacomponents,項目名稱:search,代碼行數:37,代碼來源:solr.php


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