本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}