Page 1 of 1

help using xslt_* functions

Posted: Fri Jul 02, 2004 5:44 pm
by nigma
I'm going to keep this short and simple, if you need elaboration, please say so.

I've got an xml file I want to be parsed using an xslt stylesheet. I was using the xslt_* functions (http://us3.php.net/manual/en/ref.xslt.php) but the problem is when I do this in the middle of a PHP script like follows:

Code: Select all

<?php
// Write header information (i.e. <html>, <head>, etc.)
$xml_file 	= 'xml/links.xml';
$xsl_file 	= 'xml/links.xsl';

$xslt 	= xslt_create();
$fileBase 	= 'file://' . getcwd() . '/';
xslt_set_base($xslt,$fileBase);

$result = @xslt_process($xslt, $xml_file, $xsl_file);
if (!$result) echo 'XSLT processing error: ' .xslt_error($xslt);
else echo $result;

xslt_free($xslt);
// Write footer information (i.e. </html>, </body>, etc.)
?>
I get an xml prolog where $result is outputted. This I assume is invalid / unstructured markup. If i'm correct in assuming is there a way to stop the prolog from being displayed, or do I need to change the way I'm styling the xml file? Maybe there's even a way I didn't mention:) ?

Thanks a bunch for all the help / advice provided.

Posted: Sat Jul 03, 2004 1:27 am
by nigma
Grr... this damned forum is so busy that my topic is (or should I say was? :) ) burried because no one replied. I'll show you phpBB

Posted: Sat Jul 03, 2004 1:30 am
by feyd
Just a guess, but I think it's more that most of us, have not worked with said functions.. and are reserving comment.. others may have overlooked the thread...

Posted: Sat Jul 03, 2004 1:37 am
by nigma
Each reply acts as a phpBB steriod, taking it all the way to the top. I just thought i'd have some fun while creating the steriod ;)

Posted: Sat Jul 03, 2004 1:38 am
by feyd
A search of the forums, turned up 3 pages for "xslt*", have you looked through each of the found results?

Posted: Sat Jul 03, 2004 1:54 am
by nigma
You know what feyd, I haven't done a search. I screwed up. But some good may come of this, a future searcher may enter terms that will only match in my post.

On a lighter note, I think I found a solution. Use a regex to get rid of prolog.

Thanks for the discussion.

Posted: Sat Jul 03, 2004 2:10 am
by nigma
MOTHER OF WHAT!

Why wont ereg_replace do it's freakin job!