Is it possible to have a PHP script stick the result of a variable in an XML file, in a certain place?
I'm trying to create clips for an mp3 store. My idea is to grab the ProductId from the address bar and generate a clip. for example.
$productId = $_GET['productId'];if (isset($productId) && !empty($productId)) { //code to open XML file. //code to write to certain part of XML file, see below}
Question
game_over
Is it possible to have a PHP script stick the result of a variable in an XML file, in a certain place?
I'm trying to create clips for an mp3 store. My idea is to grab the ProductId from the address bar and generate a clip. for example.
$productId = $_GET['productId'];if (isset($productId) && !empty($productId)) { //code to open XML file. //code to write to certain part of XML file, see below}<?xml version="1.0" encoding="UTF-8"?>
<playlist version="0" xmlns = "http://xspf.org/ns/0/">
<trackList>
<track>
<location>/clips/<<WRITE-PRODUCT-ID-HERE>>.mp3</location>
<image></image>
<annotation></annotation>
</track>
</trackList>
</playlist>
[/font] [font="Courier,"] <?php $productId = $_GET['productId']; if (isset($productId) && !empty($productId)) { $xml = simplexml_load_file("clips.xml"); $sxe = new SimpleXMLElement($xml->asXML()); $clip = $sxe->addChild("track"); $clip->addChild("location", $productId); $sxe->asXML("clips.xml"); } ?>i believe this will add to the XML, but how can i get it to overwrite what's already there?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts