Link to home
Start Free TrialLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

How do I match and retrieve the EMBED tag from the html source

I have html source contains embed tag and want to retrieve only that, for example the below html source, how can i retrieve embed tag ? i need with preg match ...

 i am trying like this, but does not work,
echo preg_match('<embed.+="(.+?)".+?<\/embed>',$result);
<div class="test">
    
      <embed src='http://www.saynow.com/flash/test.swf' quality="high" FlashVars="itemId=test&autoplay=0&duration=04:05&url=http://my.saynow.com" bgcolor="#ffffff" wmode="opaque" width="320" height="65" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>

    
        </div>

Open in new window

Avatar of Gk
Gk

Better you search for the string "<embed" and then the next "src" in it. and then "=" and search for the ' or " . if ' is found search for its matching '. if " is found go for its matching ". this is very easy to debug also.

and download the file thru php.
http://php.net/manual/en/function.strpos.php
the src need not be the first attribute. if the string changes to <embed name="" src = "" /> your match may not work properly. even the src may miss in the embed tag by mistake!

ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Loganathan Natarajan

ASKER

great!! works now  i was there. but some syntax error