PHP 7 Script to Convert XML Report to JSON File Using simplexml_load_string() and json_encode() Method in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments






$xml_string =  <<<XML
<?xml version='1.0' standalone='yes'?>
  <title>PHP: Behind the Parser</title>
    <name>Ms. Coder</name>
    <actor>Onlivia Actora</actor>
    <name>Mr. Coder</name>
    <actor>El ActÓr</actor>
   So, this language. It is like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
   <line>PHP solves all my web problems</line>
  <rating type="thumbs">7</rating>
  <rating type="stars">5</rating>
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml); // convert the XML string to JSON

Leave a Reply