Ruko Posted July 9, 2011 Share Posted July 9, 2011 Is there any way to turn XML data into PHP variables. I tried this code $xml = simplexml_load_file("../inc/xml/style.xml); $result = $xml->xpath("styleinfo"); // lets make sql querys to upload the XML style info to the database $name = $result[0]->name; $desc = $result[0]->description; $copyright = $result[0]->copyright; $version = $result[0]->version; $designer = $result[0]->designer; mysql_query("INSERT INTO styles (stylename, styledescription, stylecopyright, version, designer) VALUES ('$name', '$desc', '$copyright', '$version', '$designer')") or die(mysql_error()); and the XML data outputs as blank. Help pls Quote Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/ Share on other sites More sharing options...
QuickOldCar Posted July 9, 2011 Share Posted July 9, 2011 forgot a double quote $xml = simplexml_load_file("../inc/xml/style.xml"); Quote Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/#findComment-1240346 Share on other sites More sharing options...
silkfire Posted July 9, 2011 Share Posted July 9, 2011 Before adding it to the database echo it out and see what you get. Could you post some sample of the XML? Quote Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/#findComment-1240454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.