?
Solved

DomDocument::loadXML not working

Posted on 2010-01-11
7
Medium Priority
?
1,655 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:puneetdudeja
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:Kalpan
ID: 26281414
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

0
 
LVL 2

Author Comment

by:puneetdudeja
ID: 26281429
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.
0
 
LVL 2

Author Comment

by:puneetdudeja
ID: 26281471
If I remove the the "movie" parameter from <object> and "src" attribute from "embed", then also its working fine...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Kalpan
ID: 26281479
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
0
 
LVL 2

Author Comment

by:puneetdudeja
ID: 26281493
Removing the "embed" tag doesn't makes any difference, still the "loadXML()" is throwing error if only <object> tag is used.
0
 
LVL 14

Expert Comment

by:Kalpan
ID: 26281537
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
0
 
LVL 2

Accepted Solution

by:
puneetdudeja earned 0 total points
ID: 26281771
Replace "html entity" everywhere in the xml with its "entity name i.e. &amp;" or "entity code i.e. &#38;", then the "loadXML()" will work right.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question