Sorry for the late reply. I just tried this code based on the XML you posted, with the slight difference that I assumed your XML contains many elements of the tag Person. It is much simpler using SimpleXML as suggested in this question.
<?php
$xml = simplexml_load_file('path\to\doc.xml');
// With the following line you get all the Person tags
$people = $xml->Person;
foreach($people as $person) {
// For each person you get all the phoneNums tags
$phoneNumbers = $person->phoneNums;
foreach($phoneNumbers as $key => $value) {
$attributes = $value->attributes();
// We get all of the attributes, and select the one on index 0 -the ONLY attribute in this given case
if ($attributes[0]=="skype")
echo $value;
}
}
?>
This works for an XML like this:
<myXml>
<Person>
<firstName>pradeep</firstName>
<lastName>jain</lastName>
<address>
<doorNumber>287</doorNumber>
<street>2nd block</street>
<city>bangalore</city>
</address>
<phoneNums type="mobile">9980572765</phoneNums>
<phoneNums type="landline">080 42056434</phoneNums>
<phoneNums type="skype">123456</phoneNums>
</Person>
<Person>
<firstName>pradeep</firstName>
<lastName>jain</lastName>
<address>
<doorNumber>287</doorNumber>
<street>2nd block</street>
<city>bangalore</city>
</address>
<phoneNums type="mobile">1</phoneNums>
<phoneNums type="landline">2</phoneNums>
<phoneNums type="skype">3</phoneNums>
</Person>
</myXml>
However, if you want to try this with your original XML (with only one person tag), this works:
<?php
// The following loads the ROOT into $xml (in your case, the Person tag is the root)
$xml = simplexml_load_file('path\to\doc.xml');
// Then we get all its children (firstname, lastname, address, etc)
$children = $xml->children();
// Of all its children, we select the phoneNums tags and then iterate
$phoneNumbers = $children->phoneNums;
foreach($phoneNumbers as $key => $value) {
$attributes = $value->attributes();
// We get all of the attributes, and select the one on index 0 -the ONLY attribute in this given case
if ($attributes[0]=="skype")
echo $value;
}
?>