PHP XPath bir XML ayrıştırma

0 Cevap php

Aşağıdaki kodu göz önünde bulundurun:

$dom = new DOMDocument();
$dom->loadXML($file);

$xmlPath = new DOMXPath($dom);
$arrNodes = $xmlPath->query('*/item');
foreach($arrNodes as $item){
//missing code
}

The $file is an xml and each item has a title and a description. How can I display them (title and description)?

$file = "<item>
   <title>test_title</title>
   <desc>test</desc>
</item>";

0 Cevap