Monthly Archives: December 2011

How can check xml name value and attributes from xml file in php ?

$xml = simplexml_load_file(‘test.xml’);

foreach($xml as $key0 => $value){
echo “..1..[$key0] => $value”;
foreach($value->attributes() as $attributeskey0 => $attributesvalue1){
echo “________[$attributeskey0] = $attributesvalue1”;
}
echo ‘
‘;
////////////////////////////////////////////////
foreach($value as $key => $value2){
echo “….2…..[$key] => $value2”;
foreach($value2->attributes() as $attributeskey => $attributesvalue2){
echo “________[$attributeskey] = $attributesvalue2”;
}
echo ‘
‘;
////////////////////////////////////////////////
foreach($value2 as $key2 => $value3){
echo “………3……….[$key2] => $value3”;
foreach($value3->attributes() as $attributeskey2 => $attributesvalue3){
echo “________[$attributeskey2] = $attributesvalue3”;
}
echo ‘
‘;
////////////////////////////////////////////////
foreach($value3 as $key3 => $value4){
echo “……………….4………………..[$key3] => $value4”;
foreach($value4->attributes() as $attributeskey3 => $attributesvalue4){
echo “________[$attributeskey3] = $attributesvalue4”;
}
echo ‘
‘;
////////////////////////////////////////////////
foreach($value4 as $key4 => $value5){
echo “…………………5………………….[$key4] => $value5”;
foreach($value5->attributes() as $attributeskey4 => $attributesvalue5){
echo “________[$attributeskey4] = $attributesvalue5”;
}
echo ‘
‘;
////////////////////////////////////////////////
foreach($value5 as $key5 => $value6){
echo “………………….6…………………..[$key5] => $value6”;
foreach($value6->attributes() as $attributeskey5 => $attributesvalue6){
echo “________[$attributeskey5] = $attributesvalue6”;
}
echo ‘
‘;
}}}}}
echo ‘
‘;
}