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


PHP DOMDocument::createElementNs方法代码示例

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


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

示例1: visit

 /**
  * Docarate BBCode AST
  *
  * Visit the BBCode abstract syntax tree.
  *
  * @param ezcDocumentBBCodeDocumentNode $ast
  * @return mixed
  */
 public function visit(ezcDocumentBBCodeDocumentNode $ast)
 {
     // Create article from AST
     $imp = new DOMImplementation();
     $dtd = $imp->createDocumentType('article', '-//OASIS//DTD DocBook XML V4.5//EN', 'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd');
     $this->document = $imp->createDocument('http://docbook.org/ns/docbook', '', $dtd);
     $this->document->formatOutput = true;
     //        $root = $this->document->createElement( 'article' );
     $root = $this->document->createElementNs('http://docbook.org/ns/docbook', 'article');
     $this->document->appendChild($root);
     // Visit all childs of the AST root node.
     foreach ($ast->nodes as $node) {
         $this->visitNode($root, $node);
     }
     return $this->document;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:24,代码来源:docbook.php

示例2: visitEnterSelectorSequence

 /**
  * If here is already data in the buffer, add a separator before starting the next.
  *
  * @return boolean
  */
 public function visitEnterSelectorSequence()
 {
     if ($this->_current === $this->_dom->documentElement && $this->_current->hasChildNodes()) {
         $this->_current->appendChild($this->_dom->createElementNs($this->_xmlns, 'text'))->appendChild($this->_dom->createCDATASection(', '));
     }
     return $this->start($this->appendElement('selector'));
 }
开发者ID:ThomasWeinert,项目名称:PhpCss,代码行数:12,代码来源:Explain.php

示例3: initializeDocument

 /**
  * Initialize destination document
  *
  * Initialize the structure which the destination document could be build
  * with. This may be an initial DOMDocument with some default elements, or
  * a string, or something else.
  *
  * @return mixed
  */
 protected function initializeDocument()
 {
     $ezxml = new DOMDocument();
     $ezxml->formatOutput = true;
     $root = $ezxml->createElementNs('http://ez.no/namespaces/ezpublish3', 'section');
     $root->setAttribute('xmlns:image', 'http://ez.no/namespaces/ezpublish3/image/');
     $root->setAttribute('xmlns:xhtml', 'http://ez.no/namespaces/ezpublish3/xhtml/');
     $root->setAttribute('xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/');
     $ezxml->appendChild($root);
     return $root;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:20,代码来源:docbook_ezxml.php

示例4: visit

 /**
  * Docarate RST AST
  *
  * Visit the RST abstract syntax tree.
  *
  * @param ezcDocumentRstDocumentNode $ast
  * @return mixed
  */
 public function visit(ezcDocumentRstDocumentNode $ast)
 {
     parent::visit($ast);
     // Create article from AST
     $imp = new DOMImplementation();
     $dtd = $imp->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
     $this->document = $imp->createDocument('http://www.w3.org/1999/xhtml', '', $dtd);
     $root = $this->document->createElementNs('http://www.w3.org/1999/xhtml', 'html');
     $this->document->appendChild($root);
     $this->head = $this->document->createElement('head');
     $root->appendChild($this->head);
     // Append generator
     $generator = $this->document->createElement('meta');
     $generator->setAttribute('name', 'generator');
     $generator->setAttribute('content', 'eZ Components; http://ezcomponents.org');
     $this->head->appendChild($generator);
     // Set content type and encoding
     $type = $this->document->createElement('meta');
     $type->setAttribute('http-equiv', 'Content-Type');
     $type->setAttribute('content', 'text/html; charset=utf-8');
     $this->head->appendChild($type);
     $this->addStylesheets($this->head);
     $body = $this->document->createElement('body');
     $root->appendChild($body);
     // Visit all childs of the AST root node.
     foreach ($ast->nodes as $node) {
         $this->visitNode($body, $node);
     }
     // Visit all footnotes at the document body
     foreach ($this->footnotes as $footnotes) {
         ksort($footnotes);
         $footnoteList = $this->document->createElement('ul');
         $footnoteList->setAttribute('class', 'footnotes');
         $body->appendChild($footnoteList);
         foreach ($footnotes as $footnote) {
             $this->visitFootnote($footnoteList, $footnote);
         }
     }
     // Check that all required elements for a valid XHTML document exist
     if ($this->head->getElementsByTagName('title')->length < 1) {
         $title = $this->document->createElement('title', 'Empty document');
         $this->head->appendChild($title);
     }
     return $this->document;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:53,代码来源:xhtml.php

示例5: createXml

 /**
  * Create the order XML.
  *
  * @param array $data
  *   The data array to create the XML from.
  *
  * @return \DOMDocument
  *   The generated XML object.
  */
 protected function createXml(array $data)
 {
     $xml = new \DOMDocument('1.0', 'UTF-8');
     // Add the request root element.
     $request = $xml->createElementNs('http://www.euroscript.com/escaepe/types', 'tns:ClientWoRequest');
     $request->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $request->setAttribute('xsi:schemaLocation', 'http://www.euroscript.com/escaepe/types clientOrderRequestTypes.xsd');
     $xml->appendChild($request);
     // Add the data to the request in the XML.
     $this->arrayToXml($data, $request);
     return $xml;
 }
开发者ID:MPParsley,项目名称:xconnect,代码行数:21,代码来源:XmlEncoder.php

示例6: propfind

 /**
  * Retrieve properties defined on the specified resource.
  *
  * Performs a <tt>PROPFIND</tt> request as defined in the
  * {@link http://tools.ietf.org/html/rfc4918#section-9.1 Section 9.1 of RFC-4918}.
  *
  * The following options are available:
  * - <tt>properties</tt>
  * - <tt>depth</tt>
  *
  * @param string $uri
  *            Resource URI
  * @param array $options
  *            Options to apply to the request
  *            
  * @return MultiStatus
  */
 public function propfind($uri, array $options = null)
 {
     $depth = isset($options['depth']) ? (int) $options['depth'] : 0;
     $properties = isset($options['properties']) ? $options['properties'] : array();
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $xPropfind = $dom->createElementNS('DAV:', 'D:propfind');
     if (count($properties) == 0) {
         $xProp = $dom->createElement('D:allprop');
     } else {
         $xProp = $dom->createElement('D:prop');
         $namespaces = array_flip($this->xmlNamespaces);
         foreach ($properties as $property) {
             list($prefix, ) = explode(':', $property, 2);
             if ($prefix !== null && isset($namespaces[$prefix])) {
                 $xProp->setAttributeNS('http://www.w3.org/2000/xmlns/', "xmlns:{$prefix}", $namespaces[$prefix]);
                 $xPropNode = $dom->createElementNs($namespaces[$prefix], $property);
             } else {
                 $xPropNode = $dom->createElement($property);
             }
             $xProp->appendChild($xPropNode);
         }
     }
     $dom->appendChild($xPropfind)->appendChild($xProp);
     $body = $dom->saveXML();
     $request = $this->createRequest('PROPFIND', $uri, array('Content-Type' => 'Content-Type: text/xml; charset="utf-8"', 'Depth' => $depth), $body);
     $response = $this->doRequest($request);
     return $response->getStatusCode() == 207 ? MultiStatus::parse($this, $response->getBody()) : null;
 }
开发者ID:samizdam,项目名称:WebDAV,代码行数:45,代码来源:WebDavClient.php

示例7: render

 /**
  * Render the document
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  The rendered data
  *
  * @since   11.1
  */
 public function render($cache = false, $params = array())
 {
     $xml = new DOMDocument('1.0', 'utf-8');
     if (defined('JDEBUG') && JDEBUG) {
         $xml->formatOutput = true;
     }
     // The OpenSearch Namespace
     $osns = 'http://a9.com/-/spec/opensearch/1.1/';
     // Create the root element
     $elOs = $xml->createElementNs($osns, 'OpenSearchDescription');
     $elShortName = $xml->createElementNs($osns, 'ShortName');
     $elShortName->appendChild($xml->createTextNode(htmlspecialchars($this->_shortName)));
     $elOs->appendChild($elShortName);
     $elDescription = $xml->createElementNs($osns, 'Description');
     $elDescription->appendChild($xml->createTextNode(htmlspecialchars($this->description)));
     $elOs->appendChild($elDescription);
     // Always set the accepted input encoding to UTF-8
     $elInputEncoding = $xml->createElementNs($osns, 'InputEncoding');
     $elInputEncoding->appendChild($xml->createTextNode('UTF-8'));
     $elOs->appendChild($elInputEncoding);
     foreach ($this->_images as $image) {
         $elImage = $xml->createElementNs($osns, 'Image');
         $elImage->setAttribute('type', $image->type);
         $elImage->setAttribute('width', $image->width);
         $elImage->setAttribute('height', $image->height);
         $elImage->appendChild($xml->createTextNode(htmlspecialchars($image->data)));
         $elOs->appendChild($elImage);
     }
     foreach ($this->_urls as $url) {
         $elUrl = $xml->createElementNs($osns, 'Url');
         $elUrl->setAttribute('type', $url->type);
         // Results is the default value so we don't need to add it
         if ($url->rel != 'results') {
             $elUrl->setAttribute('rel', $url->rel);
         }
         $elUrl->setAttribute('template', $url->template);
         $elOs->appendChild($elUrl);
     }
     $xml->appendChild($elOs);
     parent::render();
     return $xml->saveXml();
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:52,代码来源:opensearch.php

示例8: renderXml

 /**
  * @param StdClass $resource
  * @return string
  */
 public function renderXml(StdClass $resource)
 {
     $doc = new DOMDocument("1.0", "utf-8");
     if ($resource->resourceType == "Bundle") {
         // stupid special case
         $root = $doc->createElementNs("http://www.w3.org/2005/Atom", "feed");
         $doc->appendChild($root);
         $this->renderXmlBundle($resource, $doc, $root);
     } else {
         $this->renderXmlRecursive($resource, $doc, $doc);
     }
     if (YII_DEBUG) {
         $doc->formatOutput = true;
     }
     return $doc->saveXML();
 }
开发者ID:openeyeswales,项目名称:OpenEyes,代码行数:20,代码来源:FhirMarshal.php

示例9: buildDocbookDocument

 /**
  * Build docbook document out of annotated ODT document
  *
  * @param DOMDocument $document
  * @return DOMDocument
  */
 protected function buildDocbookDocument(DOMDocument $document)
 {
     $docbook = new DOMDocument('1.0', 'utf-8');
     $docbook->preserveWhiteSpace = false;
     $docbook->formatOutput = true;
     $root = $docbook->createElementNs('http://docbook.org/ns/docbook', 'article');
     $docbook->appendChild($root);
     $xpath = new DOMXPath($document);
     $xpath->registerNamespace('office', self::NS_ODT_OFFICE);
     // @todo: Process meta data
     $body = $xpath->query('//office:body')->item(0);
     $this->transformToDocbook($body, $root);
     return $docbook;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:20,代码来源:odt.php

示例10: buildDocbookDocument

 /**
  * Build docbook document out of annotated XHtml document
  *
  * @param DOMDocument $document
  * @return DOMDocument
  */
 protected function buildDocbookDocument(DOMDocument $document)
 {
     $docbook = new DOMDocument('1.0', 'utf-8');
     $docbook->preserveWhiteSpace = false;
     $docbook->formatOutput = true;
     $root = $docbook->createElementNs('http://docbook.org/ns/docbook', 'article');
     $docbook->appendChild($root);
     $xpath = new DOMXPath($document);
     $html = $xpath->query('/*[local-name() = "html"]')->item(0);
     $this->transformToDocbook($html, $root);
     return $docbook;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:18,代码来源:xhtml.php

示例11: renderXmlBundle

 private function renderXmlBundle(StdClass $data, DOMDocument $doc, DOMNode $parent)
 {
     foreach ($data as $name => $value) {
         if ($name == 'resourceType') {
             continue;
         }
         $values = is_array($value) ? $value : array($value);
         foreach ($values as $value) {
             if ($name == 'totalResults') {
                 $el = $doc->createElementNs('http://a9.com/-/spec/opensearch/1.1/', 'os:totalResults');
             } else {
                 $el = $doc->createElement($name);
             }
             switch ($name) {
                 case 'link':
                     // value contains attributes
                 // value contains attributes
                 case 'category':
                     foreach ($value as $attrName => $attrValue) {
                         $el->setAttribute($attrName, $attrValue);
                     }
                     break;
                 case 'title':
                     // value is text content
                 // value is text content
                 case 'id':
                 case 'updated':
                 case 'published':
                 case 'totalResults':
                 case 'name':
                 case 'uri':
                     $el->appendChild($doc->createTextNode($value));
                     $parent->appendChild($el);
                     break;
                 case 'summary':
                     $frag = $doc->createDocumentFragment();
                     $frag->appendXML($value);
                     $el->appendChild($frag);
                     $el->setAttribute('type', 'xhtml');
                     $parent->appendChild($el);
                     break;
                 case 'entry':
                     // recur
                 // recur
                 case 'author':
                     $this->renderXmlBundle($value, $doc, $el);
                     break;
                 case 'content':
                     // yeah, let's get out of here!
                     $el->setAttribute('type', 'text/xml');
                     $this->renderXmlRecursive($value, $doc, $el);
                     break;
                 default:
                     throw new Exception("Unexpected item name found in Bundle: '{$name}'");
             }
             $parent->appendChild($el);
         }
     }
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:59,代码来源:FhirMarshal.php


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