Вы можете использовать код, подобный этому:
function process( DOMNode $node){
// Special handling for character data
if( $node instanceof DOMCharacterData){
return $node->data;
}
// Has only text inside:
if( ($node->childNodes->length == 1) && ($node->childNodes->item(0)->nodeName == '#text') && ($node->childNodes->item(0) instanceof DOMCharacterData)){
return $node->childNodes->item(0)->data;
}
// Get all attributes
$result = array();
foreach( $node->attributes as $item){
$result[ $item->name] = $item->value;
}
// Go trough all child nodes
foreach($node->childNodes as $sub){
$result[$sub->nodeName] = process( $sub);
}
return $result;
}
И результат:
Array
(
[Version] => 1.0
[POS] => Array
(
[Source] => Array
(
[UniqueId] => Array
(
[Id] => username:password
)
)
)
[DestinationInformation] => Array
(
[LanguageCode] => EN
)
[text] => text
)
Полезные ссылки на документацию: