How to Transform XML with XSLT using PHP in Wordpress -


Now I change an XML document with an XSLT stylesheet using Javascript (in a Wordpress-based website). It works fine in Firefox and Chrome, but not in IE Also, if Javascript is not enabled, nothing will be visible.

So, my goal is to do XHTML to XML / XSLT conversion server, not to use the client, especially PHP.

I have tried many other PHP scripts that others have written (I'm a newbie), but I can not get them to work. I included the simplest PHP script found below I know that the dynamic file path can be a problem, but I do not have a better way to locate XML and XSLT files.

When I use the script below, I get an error: Parse error: Syntax

 Optional solutions will also be welcome. 

 

  & lt ;? Php $ xml = new DOMDocument (); $ Xml- & gt; Load ('& lt ;? php bloginfo (' template_directory ') ;? & gt; rentals /works.xml'); $ Xsl = new DOMDocument; $ Xsl- & gt; Load ('& php bloginfo' ('template_directory') ;? & gt; rentals /works.xsl '); $ Proc = New XSLTProcessor (); $ Proc- & gt; ImportStyleSheet ($ XSL); Echo $ proc- & gt; Transformoaxml ($ xml); ? & Gt;  

You have to change the bit of PHP in the correct context, as follows:

  $ xml = new DOMDocument; $ Xml- & gt; Load (get_bloginfo ('template_directory'). '/rentals/works.xml'); $ Xsl = new DOMDocument; $ Xsl- & gt; Load (get_bloginfo ('template_directory'). '/rentals/works.xsl'); $ Proc = New XSLTProcessor; $ Proc- & gt; ImportStyleSheet ($ XSL); Echo $ proc- & gt; Transformoaxml ($ xml);  

Comments

Popular posts from this blog

php - multilevel menu with multilevel array -

c# - TypeConverter in propertygrid only converts from string, not to -

jQuery UI: Datepicker month format -