How to catch XML Dom with php regex

kessix

New Member
I got some XML Atom files on local.On all of those files, there are some \[code\]<author>...</author>\[/code\] balise that I want to catch in a PHP string variable.So I did that : \[code\]function parseAtomByBalise($xml,$balise) { $arrayStr=array(); preg_match('#<'.$balise.'>(.*)</'.$balise.'>#',$xml,$arrayStr); return $arrayStr;} $fxml=fopen($xml,'r'); $strXML=fgets($fxml); echo '<p>author: <textarea>'; $authors=parseAtomByBalise($strXML,'author'); foreach($authors as $author) { if($author!=$strXML) echo $author.'\n'; } echo '</textarea></p>';}\[/code\]Files are opening, and strXML is the good string.I got some stranges behaviours of preg_match, that makes me think that this is not the good function... I got more balises than only the balises insides \[code\]<author></author>\[/code\]How should I do ?
 
Back
Top