<?php

$doc = DOMDocument::loadXML('<inventory title=>...</inventory>');

$xpath = new DOMXPath($doc);

$nodelist = $xpath->query('
$result = $nodelist->item(0);

$nodelist = $xpath->query('
for($i = 0; $i < $nodelist->length; $i++)
{
  
  print $doc->saveXML($nodelist->item($i)).;
}

$nodelist = $xpath->query('

$result = array(); 

foreach($nodelist as $node)
{
  $result[] = $node; 
}