GuidesPHPBuilder: Using PHP and XML with Apache Cocoon

PHPBuilder: Using PHP and XML with Apache Cocoon

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




“First off, for those of you who don’t know what Cocoon is, check out http://xml.apache.org where you can download the source and read up on it. In short Cocoon is a suite of Java Servlets that sit on your server waiting for .xml pages and then – if applicable – it applies the relevant XSL transformations. With one XML page and different XSL pages you can deliver rendered output suitable for your Browser, for example HTML for your Desktop or WML for your WAP device.”

Prompted by a few postings to the PHP4Beta list I realised that it would be possible to employ a workaround and still use PHP, so I set off to see if I could get it to work. Needless to say I did, so here is a very simple example of using PHP to generate XML dynamically and then using Cocoon to give me browser friendly mark-up.

“I’ve been playing with Cocoon as a ‘learning’ project for some time now but my main problem has been that of generating the XML dynamicly by using PHP and then using Cocoon to do the transformations. You can’t embed PHP into a .xml page because Cocoon doesn’t recognise it and to write XSP’s I needed to learn Java, which at the current time is not an option for me.”

“Prompted by a few postings to the PHP4Beta list I realised that it would be possible to employ a workaround and still use PHP, so I set off to see if I could get it to work. Needless to say I did, so here is a very simple example of using PHP to generate XML dynamically and then using Cocoon to give me browser friendly mark-up.”

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories