Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent PHP::XSLTProcessor from generating <html> and <body> tags?

I am using php XSLTProcessor to make transformations of specific parts of XML file that I need to incorporate as a content inside another HTML document.

The problem is that XSLTProcessor always emits code like this:

<head>
<body>
[what I need to incorporate]
</body>
</head>

I need to prevent it from generating those surrounding tag, how can I do this?

like image 742
Y.H. Avatar asked Jan 01 '26 08:01

Y.H.


1 Answers

Have you tried not to use the html output method?

I would try:

<xsl:output method="xml"/>

If your XSLT processor allows custom XMLWriter classes, you may write such a class that enforces certain lexical forms (such as certain elements not having a short form or writing <br /> and never <br></br>), if such are required.

like image 61
Dimitre Novatchev Avatar answered Jan 03 '26 20:01

Dimitre Novatchev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!