As Carussell said, the best answer is not to use PHP for this. Find a library that can take care of this for you.
However, I admit that this is not always an option. With that in mind ...
, , . -, DOMDocument- > load ($ file) .
, , XPath, , .
:
$searchTerm = "text";
$doc = new DOMDocument();
$doc->load( 'musicInformation.xml' );
$xpath = new DOMXPath( $doc );
$result = $xpath->query(
'//musicdetails[ .//text()[contains( ., "'. addslashes($searchTerm) .'" )] ]'
);
echo "Found: ". $result->length ."\n";
foreach ( $result AS $node ) {
echo $doc->saveXML($node) ."\n\n";
}