?
Solved

DomDocument::loadXML not working

Posted on 2010-01-11
7
Medium Priority
?
1,575 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 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