evenin' all,
I'm using
<?
$datafile = "./datafile.xml";
//
if (!($fp = fopen($datafile, "a"))) {
die ("whoops! no file found");
}
//
$data_string = "<item>
<![CDATA[some more data I'd like to store in XML after the last child node but before the </root_node> terminus]]>
</item>";
//
fwrite($fp, $data_string);
fclose($fp);
//
?>
to pass a variable and write it into my XML document, which looks something like this
<?xml version="1.0"?>
<root_node id="root">
<item no_parse_html="1">
<item>
<![CDATA[some data I'd like to store in XML]]>
</item>
</root_node>
As you well know, XML has to be in a certain structure, and my PHP writes the string after the whole XML data, and that's no good.
How can I specify that the data must be written to the part before </root_node> but after the last child node <item>? I assume it's something simple that counts characters (in this case 12) backwards from the XML and appends the data to that section, I just can't fathom what it is, or if it's even a correct assumption?
Cheers