PHP DOMDocument simple dom xml

From Code Trash
Jump to: navigation, search

Here i have used documentelement in the above i have used getelementsbytagname

$xmlstring = '<person><firstname>samuel</firstname><lastname>jackson</lastname><address>#123, Park way drive, Alton</address><phone><landline>044-42137645</landline><mobile>919840627299</mobile><skype>874365787</skype></phone></person>';
 
$xml = new DOMDocument();
$xml->loadXML($xmlstring);
echo $xml->documentElement->childNodes->item(3)->childNodes->item(2)->nodeValue;