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


PHP DOMDocument::asXML方法代码示例

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


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

示例1: toString

 /**
  * Convert XML object to string.
  *
  * @param   \SimpleXMLElement|\DOMDocument|string  $data  XML object or data.
  *
  * @return  string  Converted XML string.
  */
 protected function toString($data)
 {
     if ($data instanceof \SimpleXMLElement) {
         return $data->asXML();
     } elseif ($data instanceof \DOMDocument) {
         return $data->saveXML();
     } elseif (is_string($data)) {
         return $data;
     }
     throw new \InvalidArgumentException(sprintf('Invalid XML content type, %s provided.', gettype($data)));
 }
开发者ID:ventoviro,项目名称:windwalker-http,代码行数:18,代码来源:XmlResponse.php

示例2: toDOMDocument

 /**
  * Convert anything DOMDocument|SimpleXMLElement|string to DOMDocument.
  *
  * @param \DOMDocument|\SimpleXMLElement|string $xml String may be filename or xml string
  *
  * @throws \InvalidArgumentException
  * @return \DOMDocument
  */
 public static function toDOMDocument($xml)
 {
     if ($xml instanceof \DOMDocument) {
         return $xml;
     }
     if ($xml instanceof \SimpleXMLElement) {
         $doc = new \DOMDocument();
         $doc->loadXML('' . $xml->asXML());
         return $doc;
     }
     if (is_string($xml)) {
         $doc = new \DOMDocument();
         if (is_file($xml)) {
             $doc->load($xml);
             return $doc;
         }
         $doc->loadXML($xml);
         return $doc;
     }
     $type = is_object($xml) ? get_class($xml) : gettype($xml);
     throw new \InvalidArgumentException("Cannot convert instance of '{$type}' to DOMDocument");
 }
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:30,代码来源:Xml.php

示例3: _setRequest

 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 private function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:35,代码来源:Server.php

示例4: _setRequest

 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         try {
             if (strlen($xml) == 0 || !($dom = Zend_Xml_Security::scan($xml, $dom))) {
                 #require_once 'Zend/Soap/Server/Exception.php';
                 throw new Zend_Soap_Server_Exception('Invalid XML');
             }
         } catch (Zend_Xml_Exception $e) {
             #require_once 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception($e->getMessage());
         }
     }
     $this->_request = $xml;
     return $this;
 }
开发者ID:lightyoruichi,项目名称:Magento-Pre-Patched-Files,代码行数:41,代码来源:Server.php

示例5: _setRequest

 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return \Zend\Soap\Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof \DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof \DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof \SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new \DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             throw new Exception\InvalidArgumentException('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:35,代码来源:Server.php

示例6: _setRequest

 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         libxml_disable_entity_loader(true);
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             require_once 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
         foreach ($dom->childNodes as $child) {
             if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
                 require_once 'Zend/Soap/Server/Exception.php';
                 throw new Zend_Soap_Server_Exception('Invalid XML: Detected use of illegal DOCTYPE');
             }
         }
         libxml_disable_entity_loader(false);
     }
     $this->_request = $xml;
     return $this;
 }
开发者ID:BGCX262,项目名称:zweer-gdr-svn-to-git,代码行数:44,代码来源:Server.php

示例7: _setRequest

 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             require_once PHP_LIBRARY_PATH . 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
开发者ID:netixx,项目名称:Stock,代码行数:36,代码来源:Server.php


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