Monday, July 8, 2013

Get value of inside of "![CDATA" In PHP

If you have XML File and in this file data was stored like this.
<![CDATA[Milano Card]]>
<![CDATA[Get all that you need at Milan and discover the heart of Europe from culture art entertainment and cuisine. Choose the service that you want and use your Milano Card for perks and discounts. Get to use public transportation for free for 3 days and gain free access to selected museums!]]>
And if you want to get this data using PHP script  then execute this code. 


  $doc = new DOMDocument();
  $doc->load('http://' . $_SERVER['HTTP_HOST'] . '/citytoursxmlfiles/city.xml' );
   $destinations = $doc->getElementsByTagName("item");
   $simpleXml = array();
   foreach ($destinations as $destination) {
            $simpleXml[] = $destination->nodeValue;
      echo json_encode($simpleXml); 


No comments:

Post a Comment