I'm dynamically creating an xml document in my php script with values from a
user form.
$xmlFile = "myxml.xml";
$fileHandle = fopen($xmlFile, 'wb') or die ('Could not open file!');
$xmlData = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
.
.
.
.
fclose($fileHandle);
all this works..a valid xml document is created just like i want
But my problem is reading it. I want to be able to insert a new element into the xml document
So this is what I do rite now:
readfile($fileName);
when i do this, it does not print the entire contents of the xml file.
It only prints the values of the elements. It skips the actual elemtns.
for example: if part of my xml is something like this
<student>
<name>John</name>
<address>123 street</address>
</student>
my code only prints
John 123 street
it skips the xml tags. I dont understand why. I've tried the other ways to read files too such as
fgets, fread, file() and it does the same. Only values of the elemtns are printed.
Someone please help me with this. Why aren't my xml tags getting printed.
Another thing i also tried was instead of making this an .xml file, i made it a simple .txt
and tried the same thing, but same result.
PLEASE help