xml node attribute reading


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>xml attribute reading example in php</title>

 <h3>xml attribute reading example in php</h3>

 $xml = simplexml_load_file("patients3.xml");
 foreach($xml->children() as $patients)
  foreach($patients->children() as $patient => $thisPatient)
   echo $thisPatient->name;
   echo "  ";
   echo $thisPatient->name['lastname'];
   | lastname is the attribute of name
   echo "  ";
   echo $thisPatient->address;
   echo "<br />";


<?xml version="1.0"?>
      <name lastname="hosan">iqbal</name>
      <name lastname="saiful">suman</name>

No comments:

Post a Comment

leave your comments here..