I have a XML created dynamically. However, I want to add a reference to an XSLT file in it, to be able to render the XML file as HTML in Mozilla.
I want my final XML to start something like this:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xslt_stylesheet_file.xsl"?>
<root_node>
</root_node>
I am not able to install XML::LibXSLT, so that is not a solution. Another solution would be to write the XML in a file, open it as a regular file and add the XSLT reference to it - but that just doesn't seem right to me.
Are there elegant solutions to this?
Edit:
Added some code
use strict;
use warnings;
use XML::LibXML;
my $final_xml = XML::LibXML::Document->new('1.0','utf-8');
my $root_node = $final_xml->createElement('root');
$final_xml->setDocumentElement( $root_node );
open (MYFILE, '>final.xml' );
print MYFILE $final_xml->toString();
close (MYFILE);
And the output is:
<?xml version="1.0" encoding="utf-8"?>
<root/>