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

XSLTProcessor::transformToXML

(PHP 5, PHP 7)

XSLTProcessor :: transformToXML - 转换为 XML

描述

代码语言:javascript
复制
string XSLTProcessor::transformToXML ( object $doc )

将源节点转换为应用由 xsltprocessor :: importStylesheet()方法给出的样式表的字符串。

参数

doc

要转换的 DOMDocument 或 SimpleXMLElement 对象。

返回值

作为字符串或FALSE错误进行转换的结果。

示例

示例#1 转换为字符串

代码语言: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?$proc->transformToXML($xml);

?>

上面的例子将输出:

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

<h1>Fight for your mind</h1><h2>by Ben Harper - 1995</h2><hr>
<h1>Electric Ladyland</h1><h2>by Jimi Hendrix - 1997</h2><hr>

也可以看看

  • XSLTProcessor :: transformToDoc() - 转换为 DOMDocument
  • XSLTProcessor :: transformToUri() - 转换为 URI

← XSLTProcessor::transformToUri

GUI Extensions →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com