Answers for "save xml url file with php"

PHP
2

php read xml from url

$xml=simplexml_load_file("filename.xml") or die("Error: Cannot create object");
echo $xml->detaildata->lattitude;
echo $xml->detaildata->longitude;
Posted by: Guest on April-22-2020
0

how to get data from xml file in php

//student.xml

<?xml version="1.0"?>
<college>
 <student>
 <firstname>Tom</firstname>
 <lastname>Cruise</lastname>
 <class>12th</class>
 <marks>456</marks>
 </student>
 <student>
 <firstname>Tyler</firstname>
 <lastname>Horne</lastname>
 <class>12th</class>
 <marks>485</marks>
 </student>
</college>
//php code


<?php
$xmldata = simplexml_load_file("student.xml") or die("Failed to load");
foreach($xmldata->children() as $empl) 
{         
 echo $empl->firstname . ", ";     
 echo $empl->lastname . ", ";     
 echo $empl->class . ", ";        
 echo $empl->marks . "<\n>"; 
} 
?>
Posted by: Guest on February-16-2022

Browse Popular Code Answers by Language