accessing xml attributes
Posted: Thu Oct 07, 2010 3:42 am
Hi,
I have a xml file with the following format.
the file name is school.xml
I am trying to access the elements and attributes of xml elements.
My code goes something like this
------------------------------------------------------------------
------------------------------------------------------------------------------
I want to know how can I access attribute "coed" of details node? Can anyone help me? Its very urgent.
Regards,
Pavan
I have a xml file with the following format.
Code: Select all
<?xml version="1.0"?>
<schools>
<school>
<id>100</id>
<type>Govt</type>
<details coed="1">
<name>ABC High School</name>
<address># 5, Bangalore</address>
<girls>120</girls>
<boys>100</boys>
<staff>25</staff>
</details>
</mk>
<mk>
<id>200</id>
<type>Pvt</type>
<details coed="0">
<name>XYZ school</name>
<address>No 121, Bangalore</address>
<girls>450</girls>
<boys>0</boys>
<staff>30</staff>>
</details>
</school>
</schools>the file name is school.xml
I am trying to access the elements and attributes of xml elements.
My code goes something like this
------------------------------------------------------------------
Code: Select all
$file=school.xml;
$xmlfile = $xmlparse->GetXMLTree($file);
foreach ($xmlfile[schools][0][school] as $schl){
foreach ($schl[DETAILS] as $detail){
$detail[NAME][0][VALUE] ---accessing <name>
$detail[ADDRESS][0][VALUE] ---accessing <address>
}
}I want to know how can I access attribute "coed" of details node? Can anyone help me? Its very urgent.
Regards,
Pavan