定义和用法
XML 是一种在 Web 上共享数据的标记语言,XML 既适用于人类可读,也适用于机器可读。XSL 扩展是 XSL 标准的实现,用于使用 libxslt 库执行 XSTL 转换。
XSLTProcessor::transformToDoc() 函数接受类 DOMNode 的对象作为参数,并通过对其应用样式表将其转换为 DOMDocument。
语法
参数
参数 | 描述 |
---|---|
doc | (必选)这是 DOMNode 类的对象,表示要转换的文档。 |
返回值
此函数在成功的情况下返回 DOMDocument 类的对象,如果失败,则返回 FALSE 的布尔值。
PHP 版本
此功能最初在 PHP 版本 5 中引入,并在所有后续版本中有效。
例子
以下是此函数的示例 -
sample.xml:
sample.xsl:
sample.php:
这将产生以下结果 -
DOMDocument Object
(
[doctype] =>
[implementation] => (object value omitted)
[documentElement] =>
[actualEncoding] =>
[encoding] =>
[xmlEncoding] =>
[standalone] => 1
[xmlStandalone] => 1
[version] => 1.0
[xmlVersion] => 1.0
[strictErrorChecking] => 1
[documentURI] =>
[config] =>
[formatOutput] =>
[validateOnParse] =>
[resolveExternals] =>
[preserveWhiteSpace] => 1
[recover] =>
[substituteEntities] =>
[nodeName] => #document
[nodeValue] =>
[nodeType] => 9
[parentNode] =>
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] =>
[attributes] =>
[ownerDocument] =>
[namespaceURI] =>
[prefix] =>
[localName] =>
[baseURI] =>
[textContent] =>
Title - JavaFX
Authors:
- Krishna
- Rajeev
)
(
[doctype] =>
[implementation] => (object value omitted)
[documentElement] =>
[actualEncoding] =>
[encoding] =>
[xmlEncoding] =>
[standalone] => 1
[xmlStandalone] => 1
[version] => 1.0
[xmlVersion] => 1.0
[strictErrorChecking] => 1
[documentURI] =>
[config] =>
[formatOutput] =>
[validateOnParse] =>
[resolveExternals] =>
[preserveWhiteSpace] => 1
[recover] =>
[substituteEntities] =>
[nodeName] => #document
[nodeValue] =>
[nodeType] => 9
[parentNode] =>
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] =>
[attributes] =>
[ownerDocument] =>
[namespaceURI] =>
[prefix] =>
[localName] =>
[baseURI] =>
[textContent] =>
Title - JavaFX
Authors:
- Krishna
- Rajeev
)