Answers for "where to put xml file in for php parsing"

PHP
0

php parse xml

$movies = new SimpleXMLElement($xmlstr);

echo $movies->movie[0]->plot;
Posted by: Guest on January-06-2021
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