首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

XSLTProcessor::transformToDoc

(PHP 5, PHP 7)

XSLTProcessor :: transformToDoc - 转换为 DOMDocument

描述

代码语言:javascript
复制
DOMDocument XSLTProcessor::transformToDoc ( DOMNode $doc )

将源节点转换为应用 XSLTProcessor :: importStylesheet()方法给出的样式表的 DOMDocument。

参数

doc

要转换的节点。

返回值

由此产生的 DOMDocument 或FALSE出错。

示例

Example#1 转换为 DOMDocument

代码语言:javascript
复制
<?php

// Load the XML source
$xml = new DOMDocument;
$xml->load('collection.xml');

$xsl = new DOMDocument;
$xsl->load('collection.xsl');

// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

echo trim($proc->transformToDoc($xml)->firstChild->wholeText);

?>

上面的例子将输出:

代码语言:javascript
复制
Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection!

也可以看看

  • XSLTProcessor :: transformToUri() - 转换为 URI
  • XSLTProcessor :: transformToXml() - 转换为 XML

← XsltProcessor::setSecurityPrefs

XSLTProcessor::transformToUri →

扫码关注腾讯云开发者

领取腾讯云代金券