I am trying to parse through the current page so that i can get the attribute of the embed tag.
The below works fine if i give a url, but instead of giving an url, i would like to parse the current page and then get the value of embed.
Also, this code is being used in a smarty template and there is a variable defined for the current url.
I tried with the variable name, but i got this error
"Call to a member function get_template_vars() on a non-object"
Can anyone help?
FYI - i am not an expert in php, so plz go easy on me.
PHP Code:
$url="http://www.xxxxx.com";
$html = file_get_contents($url);
$doc = new DOMDocument(); @$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('embed');
foreach ($tags as $tag) { echo $tag->getAttribute('src'); }
|