// parse all persons
foreach ( $document->children as $person )
{
if ( $person->name == "person" )
{
print( "Found a new person <br>" );
$firstName = "";
$lastName = "";
$descriptionName = "";
// get the name and description
foreach ( $person->children as $personAttribute )
{
switch ( $personAttribute->name )
{
case "firstname" :
{
$firstName = getAttrValue( $personAttribute, "value" );
}break;
case "lastname" :
{
$lastName = getAttrValue( $personAttribute, "value" );
}break;
case "description" :
{
// get the description text
foreach ( $personAttribute->children as $description )
{
if ( $description->type == 3 )
{
$description = $description->content;
}
}
}break;
}
}
print( "The persons firstname is: $firstName <br>" );
print( "The persons lastname is: $lastName <br>" );
print( "The persons description is: $description <br>" );
}
} |