Hi There I watched the new boston video on xml and php:

https://www.youtube.com/watch?v=TAw4uo6a0Tk

So I have a similar xml file being automatically generated such as below this xml file could have 0 - 5 names on it:

<?xml version="1.0" encoding="UTF-8"?>

<funerals>
<person>
<name>Oliver</name>
<born>1931</born>
<died>2015</died>
</person>
<person>
<name>Harry</name>
<born>1940</born>
<died>2015</died>
</person>
</funerals>

I wish to publish this information automatically to a webpage with the php code:

<?php $xml = simplexml_load_file('http://mydomain/funerals.xml');

echo $xml->person[0]->name;
echo $xml->person[0]->born.' - '.$xml->person[0]->died;

echo $xml->person[1]->name;
echo $xml->person[1]->born.' - '.$xml->person[1]->died;

echo $xml->person[2]->name;
echo $xml->person[2]->born.' - '.$xml->person[2]->died;

echo $xml->person[3]->name;
echo $xml->person[3]->born.' - '.$xml->person[2]->died;

echo $xml->person[4]->name;
echo $xml->person[4]->born.' - '.$xml->person[2]->died;

}


This works great but if there are only two people like in the above example it prints:

Oliver
1931-2015
Harry
1940-2015
-
-
-

So I need to remove the "-" for each person that is not there. Whats the easiest way check if there is a tag for a person and then if theres not don't echo anything? Have I explained myself well enough?

Appreciate your help in advance,

Blair