{"id":4255,"date":"2022-05-09T12:26:17","date_gmt":"2022-05-09T11:26:17","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4255"},"modified":"2022-05-09T13:12:25","modified_gmt":"2022-05-09T12:12:25","slug":"convert-from-xml","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/xml\/convert-from-xml","title":{"rendered":"Convert from XML"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Convert XML to json and then a PHP array<\/h4>\n\n\n\n<p>(you go via json even if you just want the PHP array)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/Make sure simplexml is installed (it should be there by default with php, but it seems to be omitted in some installs.\n    if (!function_exists('simplexml_load_file'))\n      die('Server config issue - simpleXML functions are not available.');    \/\/You can install this on ubuntu using: sudo apt-get install php-xml\n    \n    $RequestXml = \"&lt;RootElement&gt;&lt;FieldName1&gt;1&lt;\/FieldName1&gt;&lt;FieldName2&gt;123&lt;\/FieldName2&gt;&lt;\/RootElement&gt;\";\n    \n    $xml = simplexml_load_string($RequestXml, \"SimpleXMLElement\", LIBXML_NOCDATA);\n    $json = json_encode($xml);\n    $RequestArray = json_decode($json, TRUE);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Convert XML to json and then a PHP array (you go via json even if you just want the PHP array)<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[337],"tags":[],"class_list":["post-4255","post","type-post","status-publish","format-standard","hentry","category-xml"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4255"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4255\/revisions"}],"predecessor-version":[{"id":4257,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4255\/revisions\/4257"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}