In the following xml file "catalog", there are 5 variables for each book id.
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella</author>
<title>XML Developer</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
</book>
<book id="bk102">
<author>Ralls</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
</book>
<book id="bk103">
<author>Corets</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
</book>
</catalog>
How to get the json array for a particular Book id (i.e book id ="102") in php. I searched the web but could'not find the soluation in required manner. Can any body help me in this please? the xml file: www.mywebsite.com/catlog.xml
$data = json_decode($json, true);
foreach ( $data['catlog'] as $row ) {
if ($row['book id'] =='102') {
// do the work here
}
}