help using xslt_* functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

help using xslt_* functions

Post 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.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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 ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

A search of the forums, turned up 3 pages for "xslt*", have you looked through each of the found results?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

MOTHER OF WHAT!

Why wont ereg_replace do it's freakin job!
Post Reply