Jump to content

reldridge

Members
  • Posts

    18
  • Joined

  • Last visited

Community Answers

  1. reldridge's post in json to simpleXML (PHP) was marked as the answer   
    Using the below function I was able to get the exported xml data to a file in the correct format.
    // function to convert multi-dimensional array to xml function array2XML($obj, $array) { foreach ($array as $key => $value) { if(is_numeric($key)) $key = 'item' . $key; if (is_array($value)) { $node = $obj->addChild($key); array2XML($node, $value); } else { $obj->addChild($key, htmlspecialchars($value)); } } } $xml = new SimpleXMLElement('<root/>'); array2XML($xml, $json_obj); echo (($xml->asXML('data.xml')) ? 'Your XML file has been generated successfully!' : 'Error generating XML file!'); //Store data as a string to send to database //$data = $xml->asXML();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.