Simple requirement: I want to store a flat unchanged XML strings into a MySQL-DB and then fetch the string itself via php with the tags (i.e. <tag>1234</tag>).
Problem: When I fetch the string, I get the values not the entire XML string.
I store <tag>1243</tag> (done via PHPmyAdmin) then I fetch (see code below) and echo the result I get 1234 not <tag>1234</tag>.
$query = "SELECT * FROM " . $my_table_with_flat_xml_string;
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$xml_flat_file_with_the_tags_please = $row[0];
echo " ( " . $tags. ")";
}
Help!
Every node has a “name” (e.g. “tag”) and a value (e.g. “1234”, or perhaps “empty”).
You’ve got the value.
You simply want to store the name, too. Twice.
By creating the string “<” . $name . “>” . $value . “”
There are several different ways to get $name and $value – it all depends on exactly how you’re parsing your XML file.
Here’s an excellent tutorial that gives you details on using XML from PHP:
http://www.ibm.com/developerworks/xml/library/x-xmlphp1/index.html
http://www.ibm.com/developerworks/xml/library/x-xmlphp2/index.html
http://www.ibm.com/developerworks/xml/library/x-xmlphp3/index.html