I’ve been tasked with editing the PHP inside an XML file. I had no idea this was a thing people did, and I wish they didn’t, because I don’t understand it. So I tried to look it up and I came across this question and answer about how to add php to an XML file.
It seemed like a really promising QA, because the format suggested by the top answer (using “<![CDATA[” and “]]>” around the PHP is exactly what’s happening in the xml file I’ve been tasked to edit.
But now my question is… How the heck do I run the thing? It obviously can’t run just by doing php -S localhost:8000, because it’s not php. there is no <?php or ?>, so the interpreter wouldn’t know what was php and what wasn’t.
Why is there php in the xml file? and what do now that it’s already happened?
Here’s a minimal example (not the actual file I’m working with).
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="blah blah blah" active="1">
<title>blah blah</title>
<description><![CDATA[yadda yadda]]></description>
<version>1.3</version>
<url><![CDATA[http://www.foobar.com/mods/misc.php?do=producthelp&pid=hashbaz]]></url>
<versioncheckurl><![CDATA[http://www.foobar.com/mods/misc.php?do=productcheck&pid=hashbaz]]></versioncheckurl>
<dependencies>
<dependency dependencytype="vbulletin" minversion="3.5" maxversion="5.0.0" />
</dependencies>
<codes>
</codes>
<templates>
</templates>
<stylevardfns>
</stylevardfns>
<stylevars>
</stylevars>
<plugins>
<plugin active="1" executionorder="5">
<title>some plugin</title>
<hookname>some hook name</hookname>
<phpcode><![CDATA[ echo "and now we're doing php for some reason???" . $qux; ]]></phpcode>
</plugin>
</plugins>
</products>