reading only first node from xml file with php [closed]

I am trying to read the xml data in to php. I managed to read all "title" data with this scipt. Problem is that I only need first "title" element from xml! In moment I get unfortunatly all of them.How to read only first "title" node?\[code\]<?php$filename = $_SERVER['DOCUMENT_ROOT'].'images/albums/album.xml';if (file_exists($filename)) {$doc = new DOMDocument(); $doc->load($filename); $destinations = $doc->getElementsByTagName("title"); foreach ($destinations as $destination) { foreach($destination->childNodes as $child) { if ($child->nodeType == XML_CDATA_SECTION_NODE) { echo ('<br/><strong>V?rskemad pildid:</strong><br/><a href="http://stackoverflow.com/images/albums/index.html" src=""/>' . $child->textContent . '</a>'); } } } } else {die(nothing);}?>\[/code\]My xml looks something like this:\[code\]<album version="v6"><title><![CDATA[2012-06-06 NK maakondlik laager]]></title><slide> <title><![CDATA[2012 NK maakondlik laager 003]]></title><description><![CDATA[text here]]></description> <date>05.06.2012 19:12</date> <image width="1069" height="813">slides/2012 NK maakondlik laager 003.JPG</image> <thumb width="240" height="180">thumbs/2012 NK maakondlik laager 003.JPG</thumb><info filesize="3.84 MB" date="05.06.2012 19:12" resolution="3456 x 2592 px" flash="Flash did not fire, auto" focus="5.0mm" exposure="1/320s" aperture="3.4" distance="" metering="Center weighted average" cameramake="Panasonic" cameramodel="DMC-TZ5" camera="DMC-TZ5" sensor="OneChipColorArea" iso="100"/></slide><slide> <title><![CDATA[2012 NK maakondlik laager 004]]></title><description><![CDATA[text here]]></description> <date>05.06.2012 19:22</date> <image width="1069" height="813">slides/2012 NK maakondlik laager 004.JPG</image> <thumb width="240" height="180">thumbs/2012 NK maakondlik laager 004.JPG</thumb><info filesize="4.07 MB" date="05.06.2012 19:22" resolution="3456 x 2592 px" flash="Flash did not fire, auto" focus="5.0mm" exposure="1/250s" aperture="3.4" distance="" metering="Center weighted average" cameramake="Panasonic" cameramodel="DMC-TZ5" camera="DMC-TZ5" sensor="OneChipColorArea" iso="100"/></slide>\[/code\]
 
Back
Top