当前位置: 首页>>代码示例>>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;未经允许,请勿转载。