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


PHP fDOMDocument::loadXML方法代码示例

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


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

示例1: getCacheDom

 private function getCacheDom()
 {
     if ($this->cacheDom === NULL) {
         $this->cacheDom = new fDOMDocument();
         $cacheFile = $this->config->getLogfilePath();
         if (file_exists($cacheFile)) {
             $this->cacheDom->load($cacheFile);
             $sha1 = $this->cacheDom->documentElement->getAttribute('sha1');
             $cwd = getcwd();
             chdir($this->config->getSourceDirectory());
             exec($this->config->getGitBinary() . ' diff --name-only ' . $sha1, $files, $rc);
             foreach ($files as $file) {
                 $fields = array('path' => dirname($file), 'file' => basename($file));
                 $query = $this->cacheDom->prepareQuery('//*[@path = :path and @file = :file]', $fields);
                 $node = $this->cacheDom->queryOne($query);
                 if (!$node) {
                     continue;
                 }
                 $node->parentNode->removeChild($node);
             }
             chdir($cwd);
         } else {
             $this->cacheDom->loadXML('<?xml version="1.0" ?><gitlog xmlns="' . self::GITNS . '" />');
             $this->cacheDom->documentElement->setAttribute('sha1', $this->commitSha1);
         }
     }
     return $this->cacheDom;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:28,代码来源:Git.php

示例2: createPhpDoxConfig

 /**
  * @param string[] $units
  * @param string[] $visibilities
  * @return fDOMDocument
  */
 private function createPhpDoxConfig(array $units, array $visibilities)
 {
     $dom = new fDOMDocument();
     $dom->loadXML($this->factory->getConfigSkeleton()->renderStripped());
     $dom->registerNamespace('config', ConfigLoader::XMLNS);
     // set up silent
     $silent = $this->output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL ? 'true' : 'false';
     $dom->queryOne('//config:phpdox')->setAttribute('silent', $silent);
     // set up directories
     $projectNode = $dom->queryOne('//config:project');
     $projectNode->setAttribute('source', $this->sourceDirectory);
     $projectNode->setAttribute('workdir', $this->buildDirectory);
     // inject flag to avoid unecessary processing according to the visibility filter
     if (1 === count($visibilities) && in_array('public', $visibilities)) {
         $collectorNode = $dom->queryOne('//config:collector');
         $projectNode->setAttribute('publiconly', 'true');
     }
     // remove current masks
     $query = "//config:collector/*[name()='include' or name()='exclude']";
     foreach ($dom->query($query) as $mask) {
         $mask->parentNode->removeChild($mask);
     }
     // append files to be parsed
     $collector = $dom->queryOne('//config:collector');
     foreach ($units as $unitFile) {
         $include = $dom->createElement('include');
         $include->setAttribute('mask', $unitFile);
         $collector->appendChild($include);
     }
     return $dom;
 }
开发者ID:renanbr,项目名称:phpact,代码行数:36,代码来源:MetadataCollector.php

示例3: testQueryReturnsNodeFromClonedDocument

 /**
  * https://github.com/theseer/fDOMDocument/issues/15
  */
 public function testQueryReturnsNodeFromClonedDocument()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><test />');
     $clone = clone $this->dom;
     $node = $clone->queryOne('/test');
     $this->assertNotSame($this->dom->documentElement, $node);
 }
开发者ID:KingNoosh,项目名称:Teknik,代码行数:10,代码来源:fDOMDocument.test.php

示例4: testGetChildrenByTagnameNSReturnsCorrectNodelist

 public function testGetChildrenByTagnameNSReturnsCorrectNodelist()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><root xmlns="test:uri"><node><child/></node><node /></root>');
     $this->node = $this->dom->documentElement;
     $list = $this->node->getChildrenByTagNameNS('test:uri', 'node');
     $this->assertInstanceOf('DOMNodeList', $list);
     $this->assertEquals(2, $list->length);
 }
开发者ID:klikar3,项目名称:yii2-RGraph,代码行数:8,代码来源:fDOMElement.test.php

示例5: renderStripped

 /**
  * @return string
  */
 public function renderStripped()
 {
     $dom = new fDOMDocument();
     $dom->preserveWhiteSpace = FALSE;
     $dom->loadXML(preg_replace("/\\s{2,}/u", " ", $this->render()));
     foreach ($dom->query('//comment()') as $c) {
         $c->parentNode->removeChild($c);
     }
     $dom->formatOutput = TRUE;
     return $dom->saveXML();
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:14,代码来源:ConfigSkeleton.php

示例6: toXML

 /**
  * @param string $source
  *
  * @return fDOMDocument
  *
  * @throws \TheSeer\fDOM\fDOMException
  */
 public function toXML($source)
 {
     $this->writer = new \XMLWriter();
     $this->writer->openMemory();
     $this->writer->setIndent(true);
     $this->writer->startDocument();
     $this->writer->startElement('source');
     $this->writer->writeAttribute('xmlns', 'http://xml.phpdox.net/token');
     $this->writer->startElement('line');
     $this->writer->writeAttribute('no', 1);
     $this->lastLine = 1;
     $tokens = token_get_all($source);
     foreach ($tokens as $pos => $tok) {
         if (is_string($tok)) {
             $line = 1;
             $step = 1;
             while (!is_array($tokens[$pos - $step])) {
                 $step++;
                 if ($pos - $step == -1) {
                     break;
                 }
             }
             if ($pos - $step != -1) {
                 $line = $tokens[$pos - $step][2];
                 $line += count(preg_split('/\\R+/', $tokens[$pos - $step][1])) - 1;
             }
             $token = array('name' => $this->map[$tok], 'value' => $tok, 'line' => $line);
             $this->addToken($token);
         } else {
             $line = $tok[2];
             $values = preg_split('/\\R+/Uu', $tok[1]);
             foreach ($values as $v) {
                 $token = array('name' => token_name($tok[0]), 'value' => $v, 'line' => $line);
                 $this->addToken($token);
                 $line++;
             }
         }
     }
     $this->writer->endElement();
     $this->writer->endElement();
     $this->writer->endDocument();
     $dom = new fDOMDocument();
     $dom->preserveWhiteSpace = false;
     $dom->loadXML($this->writer->outputMemory());
     return $dom;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:53,代码来源:Tokenizer.php

示例7: showSkeletonConfig

 private function showSkeletonConfig($strip)
 {
     $config = file_get_contents(__DIR__ . '/config/skeleton.xml');
     if ($strip) {
         $config = preg_replace("/\\s{2,}/u", " ", $config);
         $dom = new fDOMDocument();
         $dom->preserveWhiteSpace = FALSE;
         $dom->loadXML($config);
         foreach ($dom->query('//comment()') as $c) {
             $c->parentNode->removeChild($c);
         }
         $dom->formatOutput = TRUE;
         $config = $dom->saveXML();
     }
     echo $config;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:16,代码来源:CLI.php

示例8: setUp

 public function setUp()
 {
     $this->dom = new fDOMDocument();
     $this->dom->loadXML('<?xml version="1.0" ?><root><node attr="foo" /></root>');
     $this->xp = $this->dom->getDOMXPath();
 }
开发者ID:klikar3,项目名称:yii2-RGraph,代码行数:6,代码来源:fDOMXPath.test.php


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