Link to home
Start Free TrialLog in
Avatar of puneetdudeja
puneetdudejaFlag for India

asked on

DomDocument::loadXML not working

My following code in PHP is not working :-

But ,if I assign  "<object><embed></embed></object>" to $code, then its working correctly.

Any help is appreciated..
$code  = '<object width="425" height="344">	
			<param name="movie" value="http://www.youtube.com/v/O68vsj_DHXU&hl=en_US&fs=1"></param>
			<param name="allowFullScreen" value="true"></param>
			<param name="allowscriptaccess" value="always"></param>
			
			<embed src="http://www.youtube.com/v/O68vsj_DHXU&hl=en_US&fs=1" 
			type="application/x-shockwave-flash" width="425" height="344" 
			allowscriptaccess="always" allowfullscreen="true">
			</embed>
		</object>';



		$doc = new DomDocument();
		$doc->loadXML($code);

Open in new window

Avatar of Kalpan
Kalpan
Flag of India image

Please use the code as below for object to be embeded...

use the following format: place your links as per the below

$code = '<object type="application/x-shockwave-flash" style="width:425px; height:350px;"
                  data="http://www.youtube.com/v/7_6B6vwE83U"><param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U" /></object>';

Hope this will help...

Thanks

Kalpan
$code = '<object type="application/x-shockwave-flash" style="width:425px; height:350px;" 
			data="http://www.youtube.com/v/7_6B6vwE83U"><param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U" /></object>';

Open in new window

Avatar of puneetdudeja

ASKER

I can't modify the code for embedding the object.

It is being filled by the user of our site and is coming directly from the database from his account.
If I remove the the "movie" parameter from <object> and "src" attribute from "embed", then also its working fine...
XHTML 1.0 compliant website that embedded a video from YouTube, you must be getting validation errors related to YouTube's use of the <embed> tag, which has been deprecated in XHTML 1.0.

If you're looking to embed a YouTube video in your website's code and want to retain your validity...

may be you can change the code when the client of your website insert the data for the code to embed...and let the proper data go to your database...

it may be the client side third party you can contact or modify the input for your website...

thanks,

Kalpan
Removing the "embed" tag doesn't makes any difference, still the "loadXML()" is throwing error if only <object> tag is used.
you must be getting the following error...or something similar

DOMDocument::loadXML() [<a href='domdocument.loadxml'>domdocument.loadxml</a>]: EntityRef: expecting ';' in Entity, line: 1

so even if you remove the some tag but u still missing the validation with object tag which is non-compliant with XHTML ....

Please try doing this on simple php page....

Kalpan
ASKER CERTIFIED SOLUTION
Avatar of puneetdudeja
puneetdudeja
Flag of India 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