Comparison JSON and XML parsing with PHP it’s easy

unduhan

Comparison JSON and XML parsing with PHP it’s easy.

PHP SimpleXML Introduction

SimpleXML is an extension that allows us to easily manipulate and get XML data.

Installation

As of PHP 5, the SimpleXML functions are part of the PHP core. No installation is required to use these functions.

SimpleXML provides an easy way of getting an element’s name, attributes and textual content if you know the XML document’s structure or layout.

download

SimpleXML turns an XML document into a data structure you can iterate through like a collection of arrays and objects.

<?php
  $url = "http://data.bmkg.go.id/cuaca_indo_1.xml";
  $sUrl = file_get_contents($url, False);
  $xml = simplexml_load_string($sUrl);


for ($i=0; $i<sizeof($xml->Isi->Row); $i++) { 
	 $row = $xml->Isi->Row[$i];
?>

<a href="detailcuaca.php?detail=<?php echo $row->Kota; ?>"><?php echo $row->Kota; ?></a>
<?php echo "

Data Cuaca : ".$row->Cuaca." 

"; ?>
	

	   
<?php }?>
Advertisements