Hi! I trying to parse a xml file with this method; $feed="http://www.ersinacar.com/video.xml"; $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, $feed); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $xml = curl_exec($ch); curl_close($ch); //echo $xml; preg_match_all("/<video videoId=\"(.*?)\" permalinkId=\"(.*?)\" extension=\"(.*?)\" length=\"(.*?)\" size=\"(.*?)\" fileHash=\"(.*?)\" tags=\"(.*?)\" previewHash=\"(.*?)\" previewHashLow=\"(.*?)\" highResImage=\"(.*?)\" medResImage=\"(.*?)\" username=\"(.*?)\" writerName=\"(.*?)\" directorName=\"(.*?)\" producerName=\"(.*?)\" castName=\"(.*?)\" studio=\"(.*?)\" screenFormat=\"(.*?)\" copyRightOwner=\"(.*?)\" releaseDate=\"(.*?)\" views=\"(.*?)\" rating=\"(.*?)\" numRatingVotes=\"(.*?)\" numDownloads=\"(.*?)\" numViews=\"(.*?)\" description=\"(.*?)\" title=\"(.*?)\" dateAdded=\"(.*?)\" age=\"(.*?)\" primaryCollectionPermalink=\"(.*?)\" primaryCollectionTitle=\"(.*?)\" primaryCollectionThumb=\"(.*?)\" allowEmbedding=\"(.*?)\" premium=\"(.*?)\" contentRatingId=\"(.*?)\" category=\"(.*?)\" numOfComments=\"(.*?)\">/i",$xml,$out,PREG_SET_ORDER); print_r($out); PHP: but it's not working. any idea? Thanks.
If all you're doing is parsing xml, you might try simplexml. Look it up on php.net. It's a really good library
regular expressions for xml can get messy quick. i would suggest actually using php's built in xml parser and doing it that way. in the end, it's much easier... www.php.net/xml http://us2.php.net/manual/en/function.xml-parser-create.php
i tiried xml_parser exp. but it's not working. used on my xml file and result Array ( [ok] => Array ( [1] => Array ( [1054] => Array ( [TAGLIST] => [THUMBNAILLIST] => ) [1907] => Array ( [TAGLIST] => [THUMBNAILLIST] => ) ) ) ) PHP: it can't parse videos..
because in order to use it, you need to get rid of all of the attributes and put them in their own tags... <rsp> <videos> <video> <title>some title</title> <length>12:34</length> <tags>jay cross blogs bloggers theweblogproject opensource robin good</tags> </video> <video> <title>another title</title> <length>1:34</length> <tags>jay cross blogs bloggers theweblogproject opensource robin good</tags> </video> </videos> </rsp> Code (markup):