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


PHP DOMDocument::saveXML方法代码示例

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


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

示例1: process

 public function process($xml)
 {
     $this->step = 0;
     $xml = $this->preprocessXml($xml);
     $xml = $this->handleSimpleSnippets($xml);
     // Add a snippet to trigger a process
     $snippetCount = count($this->parseSnippetsInString($xml));
     if ($snippetCount == 0) {
         $xml .= "<filler>[str_replace('a','b','c')]</filler>";
     }
     // While we have snippets
     while ($snippetCount = count($this->parseSnippetsInString($xml))) {
         $this->step++;
         $xml = '<root>' . $xml . '</root>';
         $this->initVariables($xml);
         $root = $this->dom->getElementsByTagName("root");
         $this->dom->recover = true;
         $this->parseElement($root->item(0));
         $this->dom->preserveWhiteSpace = false;
         $this->dom->formatOutput = true;
         $response = $this->dom->saveXML($this->dom);
         $xml = $this->cleanResponse($xml, $response);
         if ($this->step > 8) {
             throw new WpaeTooMuchRecursionException('Too much recursion');
         }
     }
     $xml = $this->postProcessXml($xml);
     $xml = $this->decodeSpecialCharacters($xml);
     $xml = $this->encodeSpecialCharsInAttributes($xml);
     return $xml;
 }
开发者ID:soflyy,项目名称:wp-all-export,代码行数:31,代码来源:WpaeXmlProcessor.php

示例2: DOMDocument

 function hook_article_filter($article)
 {
     if (strpos($article["link"], "taz.de") !== FALSE) {
         $doc = new DOMDocument();
         @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8"));
         $basenode = false;
         if ($doc) {
             $xpath = new DOMXPath($doc);
             // first remove advertisement stuff
             $stuff = $xpath->query('(//script)|(//noscript)|(//iframe)|(//style)|(//div[@class="sectfoot"])|(//div[@id="tzi_paywall"])|(//div[contains(@class, "rack")])');
             foreach ($stuff as $removethis) {
                 _debug("Remove1: " . $doc->saveXML($removethis));
                 $removethis->parentNode->removeChild($removethis);
             }
             $entries = $xpath->query('(//div[@class="sectbody"])');
             foreach ($entries as $entry) {
                 $basenode = $entry;
                 break;
             }
             if ($basenode) {
                 _debug("Result: " . $doc->saveXML($basenode));
                 $article["content"] = $doc->saveXML($basenode);
             }
         }
     }
     return $article;
 }
开发者ID:EduardBaer,项目名称:Tiny-Tiny-RSS-Plugins,代码行数:27,代码来源:init.php

示例3: __toString

 public function __toString()
 {
     $xml = '<x xmlns="jabber:x:data" type="submit"></x>';
     $node = new \SimpleXMLElement($xml);
     foreach ($this->_data as $key => $value) {
         $field = $node->addChild('field');
         if ($value == 'true') {
             $value = '1';
         }
         if ($value == 'false') {
             $value = '0';
         }
         $field->addChild('value', trim($value->value));
         /*if(isset($value->attributes->required))
           $field->addChild('required', '');*/
         $field->addAttribute('var', $value->attributes->name);
         //$field->addAttribute('type', $value->attributes->type);
         //$field->addAttribute('label', $value->attributes->label);
     }
     $xml = $node->asXML();
     $doc = new \DOMDocument();
     $doc->loadXML($xml);
     $doc->formatOutput = true;
     return substr($doc->saveXML(), strpos($doc->saveXML(), "\n") + 1);
 }
开发者ID:Hywan,项目名称:moxl,代码行数:25,代码来源:Form.php

示例4: Error

 public function Error($errorNo, $errorMessage = '')
 {
     header('Content-Type: text/xml; charset=utf8');
     Debug::LogEntry('audit', $errorMessage, 'RestXml', 'Error');
     // Roll back any open transactions if we are in an error state
     try {
         $dbh = PDOConnect::init();
         $dbh->rollBack();
     } catch (Exception $e) {
         Debug::LogEntry('audit', 'Unable to rollback');
     }
     // Output the error doc
     $xmlDoc = new DOMDocument('1.0');
     $xmlDoc->formatOutput = true;
     // Create the response node
     $rootNode = $xmlDoc->createElement('rsp');
     // Set the status to OK
     $rootNode->setAttribute('status', 'error');
     // Append the response node as the root
     $xmlDoc->appendChild($rootNode);
     // Create the error node
     $errorNode = $xmlDoc->createElement('error');
     $errorNode->setAttribute('code', $errorNo);
     $errorNode->setAttribute('message', $errorMessage);
     // Add the error node to the document
     $rootNode->appendChild($errorNode);
     // Log it
     Debug::LogEntry('audit', $xmlDoc->saveXML());
     // Return it as a string
     return $xmlDoc->saveXML();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:31,代码来源:restxml.class.php

示例5: pre_save

 protected function pre_save(&$object)
 {
     $errors = array();
     libxml_use_internal_errors(TRUE);
     $cleaned = array();
     foreach ($object['registry'] as $section => $xml) {
         $dom = new DOMDocument('1.0');
         $dom->formatOutput = FALSE;
         if (strlen(trim($xml)) == 0) {
             kohana::log('debug', 'Section: ' . $section . ' Empty XML');
             unset($cleaned[$section]);
             continue;
         }
         try {
             if ($dom->loadXML('<root>' . trim($xml) . '</root>')) {
                 $cleaned[$section] = trim(str_replace('<?xml version="1.0"?>', '', $dom->saveXML()));
                 kohana::log('debug', 'Section: ' . $section . ' Cleaned XML: ' . $dom->saveXML());
                 continue;
             } else {
                 $errors[] = ucfirst($section);
             }
         } catch (Exception $e) {
             $errors[] = ucfirst($section);
         }
     }
     if (count($errors) > 0) {
         throw new Exception('Please correct the XML errors in these sections: ' . implode(', ', $errors));
     }
     $object['registry'] = $cleaned;
     kohana::log('debug', 'Successfully validated XML');
     parent::pre_save($object);
 }
开发者ID:swk,项目名称:bluebox,代码行数:32,代码来源:featurecode.php

示例6: debugOutput

 public function debugOutput()
 {
     $this->doc->preserveWhiteSpace = false;
     $this->doc->formatOutput = true;
     echo CHtml::encode($this->doc->saveXML());
     die;
 }
开发者ID:andi98,项目名称:antragsgruen,代码行数:7,代码来源:OOfficeTemplateEngine.php

示例7: copyForDeployment

    /**
     * Copy ServiceConfiguration over to build directory given with target path
     * and modify some of the settings to point to development settings.
     *
     * @param string $targetPath
     * @return void
     */
    public function copyForDeployment($targetPath, $development = true)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->loadXML($this->dom->saveXML());
        $xpath = new \DOMXpath($dom);
        $xpath->registerNamespace('sc', $dom->lookupNamespaceUri($dom->namespaceURI));
        $settings = $xpath->evaluate('//sc:ConfigurationSettings/sc:Setting[@name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"]');
        foreach ($settings as $setting) {
            if ($development) {
                $setting->setAttribute('value', 'UseDevelopmentStorage=true');
            } else {
                if (strlen($setting->getAttribute('value')) === 0) {
                    if ($this->storage) {
                        $setting->setAttribute('value', sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $this->storage['accountName'], $this->storage['accountKey']));
                    } else {
                        throw new \RuntimeException(<<<EXC
ServiceConfiguration.csdef: Missing value for
'Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString'.

You have to modify the app/azure/ServiceConfiguration.csdef to contain
a value for the diagnostics connection string or better configure
'windows_azure_distribution.diagnostics.accountName' and
'windows_azure_distribution.diagnostics.accountKey' in your
app/config/config.yml

If you don't want to enable diagnostics you should delete the
connection string elements from ServiceConfiguration.csdef file.
EXC
);
                    }
                }
            }
        }
        $dom->save($targetPath . '/ServiceConfiguration.cscfg');
    }
开发者ID:senthilkumar3282,项目名称:AzureDistributionBundle,代码行数:42,代码来源:ServiceConfiguration.php

示例8: Write

function Write($title1, $title2, $author1, $author2, $publisher1, $publisher2)
{
    $books = array();
    $books[] = array('title' => $title1, 'author' => $author1, 'publisher' => $publisher1);
    $books[] = array('title' => $title2, 'author' => $author2, 'publisher' => $publisher2);
    $dom = new DOMDocument();
    $dom->formatOutput = true;
    $r = $dom->createElement("books");
    $dom->appendChild($r);
    foreach ($books as $book) {
        $b = $dom->createElement("book");
        $author = $dom->createElement("author");
        $author->appendChild($dom->createTextNode($book['author']));
        $b->appendChild($author);
        $title = $dom->createElement("title");
        $title->appendChild($dom->createTextNode($book['title']));
        $b->appendChild($title);
        $publisher = $dom->createElement("publisher");
        $publisher->appendChild($dom->createTextNode($book['publisher']));
        $b->appendChild($publisher);
        $r->appendChild($b);
    }
    global $diretorio;
    $fileSave = rand(100000000, 900000000) . ".xml";
    $dir_fileSave = $diretorio . $fileSave;
    $fp = fopen($dir_fileSave, "a");
    $escreve = fwrite($fp, $dom->saveXML());
    fclose($fp);
    echo "<div style='min-height:100px;background-color:rgba(255,255,255,0.2);margin-top:15px;padding:5px;border:1px solid gray;margin-bottom:15px;'>";
    echo "<div style='font-weight:bold;color:yellow;'>Xml gerado com sucesso!<br/>Nome do arquivo: {$fileSave}</div>";
    echo "<pre style='color:yellow;'>" . $dom->saveXML() . "</pre>";
    echo "</div>";
}
开发者ID:pedradanamente,项目名称:14.8.3,代码行数:33,代码来源:index.php

示例9: loadFile

 /**
  * Load XML file
  *
  * @param string $filepath
  * @return void
  */
 protected function loadFile($filepath)
 {
     $this->xmlDoc = new \DOMDocument('1.0', 'utf-8');
     $this->xmlDoc->load($filepath);
     // @TODO: oliver@typo3.org: I guess this is not required here
     $this->xmlDoc->saveXML();
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:13,代码来源:TypoScriptReferenceLoader.php

示例10: testGetProperties

 /**
  * test testGetProperties method
  */
 public function testGetProperties()
 {
     $body = '<?xml version="1.0" encoding="utf-8"?>
              <propfind xmlns="DAV:">
                 <prop>
                     <getlastmodified xmlns="DAV:"/>
                     <getcontentlength xmlns="DAV:"/>
                     <resourcetype xmlns="DAV:"/>
                     <getetag xmlns="DAV:"/>
                     <id xmlns="http://owncloud.org/ns"/>
                 </prop>
              </propfind>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/remote.php/webdav/' . Tinebase_Core::getUser()->accountDisplayName, 'HTTP_DEPTH' => '0'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     //var_dump($this->response->body);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('owncloud', 'http://owncloud.org/ns');
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/owncloud:id');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:30,代码来源:OwnCloudTest.php

示例11: loadSX

 function loadSX()
 {
     $xml = simplexml_load_file($this->_xml);
     $newDoc = new DOMDocument();
     $products = $newDoc->createElement("Allitems");
     foreach ($xml as $product) {
         $domDoc = new DOMDocument();
         $domDoc->loadXML($product->asXML());
         $x = $domDoc->documentElement;
         if (!$domDoc->schemaValidate($this->_xsd)) {
             $errors = libxml_get_errors();
             foreach ($errors as $error) {
                 //print libxml_display_error($error);
             }
             libxml_clear_errors();
         } else {
             print "validation successful\n";
             $item = $newDoc->createElement("Item");
             $i = 1;
             foreach ($x->childNodes as $ele) {
                 if (!$ele instanceof DOMElement) {
                     continue;
                 }
                 $nodeData = $newDoc->createElement(trim($ele->nodeName), $ele->nodeValue);
                 $item->appendChild($nodeData);
             }
             $products->appendChild($item);
             $newDoc->appendChild($products);
             $newDoc->formatOutput = true;
             print $newDoc->saveXML();
         }
     }
     print_r($newDoc->saveXML());
 }
开发者ID:johnalvn,项目名称:xmltranslator,代码行数:34,代码来源:XmlTrasnlator.php

示例12: saveXML

 /**
  * Recuperer la configuration au format XML.
  */
 public function saveXML()
 {
     $existing = array();
     $attributes = $this->domdocument->getElementsByTagName('attribute');
     foreach ($attributes as $attribute) {
         $existing[$attribute->getAttribute('name')] = $attribute;
     }
     if ($this->domdocument->getElementsByTagName('config')->item(0) == null) {
         $root = $this->domdocument->createElement('config');
         $this->domdocument->appendChild($root);
     } else {
         $root = $this->domdocument->getElementsByTagName('config')->item(0);
     }
     foreach ($this->config as $attribute => $value) {
         if (array_key_exists($attribute, $existing)) {
             $node = $existing[$attribute];
         } else {
             $node = $this->domdocument->createElement('attribute');
             $root->appendChild($node);
             $node->setAttribute('name', $attribute);
         }
         $node->setAttribute('value', $value);
     }
     $configNodes = $root->getElementsByTagName('attribute');
     foreach ($configNodes as $node) {
         if (!array_key_exists($node->getAttribute('name'), $this->config)) {
             $root->removeChild($node);
         }
     }
     $out = $this->domdocument->saveXML();
     return $out;
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:35,代码来源:Config.class.php

示例13: export

 /**
  * @param DOMNode $node
  */
 public function export(DOMNode $node = null)
 {
     if ($node === null) {
         return $this->_document->saveXML();
     } else {
         return $this->_document->saveXML($node);
     }
 }
开发者ID:unpush,项目名称:p2-php,代码行数:11,代码来源:P2DOM.php

示例14: dumpSchema

 /**
  * Dumps a single Schema model into an XML formatted version.
  *
  * @param  Schema  $schema                The schema object
  * @param  boolean $doFinalInitialization Whether or not to validate the schema
  * @return string
  */
 public function dumpSchema(Schema $schema, $doFinalInitialization = true)
 {
     $rootNode = $this->document->createElement('app-data');
     $this->document->appendChild($rootNode);
     foreach ($schema->getDatabases($doFinalInitialization) as $database) {
         $this->appendDatabaseNode($database, $rootNode);
     }
     return trim($this->document->saveXML());
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:16,代码来源:XmlDumper.php

示例15: finaliseStoreData

 protected function finaliseStoreData()
 {
     // Write DOM to file
     $filename = $this->info("clean_store_name") . '-products.xml';
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $this->getPath()));
     $io->write($filename, $this->_dom->saveXML());
     $io->close();
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:10,代码来源:Xml.php


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