Load('root.xml'); $child1 = $xmldoc->getElementsByTagName('child1')->item(0); echo ""; echo "Checking Attribute Example"; echo ""; if($child1 ->hasAttribute('name')){ echo "Attribute value :".$child1->getAttribute('name'); }else{ echo "Attribute 'name' does not exist
"; } if($child1 ->hasAttribute('chield1_attribute')){ echo "chield1_attribute value :".$child1->getAttribute('chield1_attribute'); }else{ echo "Attribute 'chield1_attribute' does not exist"; } echo "
"; ?>