PDA

View Full Version : XML error message



jendelaniaga
07-11-2008, 10:47 PM
My blog (http://jendelaniaga.blogspot.com)

Hi admin.
This is my first visit to your forum after using some of the scripts from your site. I have problem with some of them which was causing an error message showed up during preview i.e;
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The entity name must immediately follow the '&' in the entity reference.

I was trying to use the autumn and shaking button scripts but failed. Any help you might offer is very much appreciated.

Thanks

thetestingsite
07-11-2008, 11:04 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Usually that error has to do with links in the page that are passing variables. For example:



link.php?id=1&do=something


Should be written as so:



link.php?id=1&do=something


Hope this helps.

jendelaniaga
07-14-2008, 05:45 AM
Hi Mod.
Thanks for your reply and sorry for the forgotten link.
Let me try this again.

link to the DD script
1.Shake Image script (http://www.dynamicdrive.com/dynamicindex4/shake.htm)
2.Autumn leaves (http://www.dynamicdrive.com/dynamicindex3/leaves.htm)

These both scripts and some others produce the exactly same error message during the preview;
"Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The entity name must immediately follow the '&' in the entity reference."

Your attention and update on this matter is very very much appreciated.

jendelaniaga
07-23-2008, 10:57 AM
Hi everybody.
Regarding the previously posted error message, it's fixed by replacing the '&&' character on the script to '&' Thanks to moderator. But another error message displayed during preview i.e;
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The content of elements must consist of well-formed character data or markup.
I'm not good at all with the computer language make it impossible for me to figure out what else should be done to make the script works on my site. :(

BTW, this is the original script I'm trying to use.

<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">

/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>

It's a script for "shaking image"

Hoping that someone could lend me a hand on this matter.
Thanks

jscheuer1
07-23-2008, 02:30 PM
It might be the symbol. Try replacing it with the word copyright:


/*
Shake image script (onMouseover)-
copyright Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

jendelaniaga
07-23-2008, 04:20 PM
Hi John.
Thanks for the advice but it didn't work. Maybe I'll just surf the entire forum for the similar problem (if there is any).
Thanks again.

jscheuer1
07-23-2008, 07:13 PM
Well you shouldn't really be using xml, but that may not be an option with your blog package. Generally though, if a script is in an external file, it will not cause problems like that.

With xml, you can also use cdata comment blocks to tell the browser not to parse the script as xml:

http://www.w3schools.com/XML/xml_cdata.asp

One other thought I had is that - I don't know which agent is giving you those errors. Depending upon the agent, the errors you are reporting may have no effect upon the rendering of the page or upon the execution of the script.

jendelaniaga
07-24-2008, 04:57 AM
Hi John!! Thanks for the infos. I've tried using the cdata comment blocks. yup!! There was no more xml error message but, an attention mark appeared at the bottom-left corner of my browser indicating the syntax error and the image that supposed to shake didn't.
I'll check with my blog agent (blogger) on what should be done to make it possible to use this script on my site. Many thanks for spending your precious time on this problem, John.

P.S. In a glance i found that the w3schools.com is quite informative site that I can start learning XML from the beginning. Thanks for sharing.

jscheuer1
07-24-2008, 06:52 AM
Well you are making progress! That new warning/error you got is just a common garden variety javascript error. If you put the script back on the page and let me know what image it is supposed to shake, I can probably fix that.

A little word of caution about w3schools. I've always found their information accurate, but there have been several complaints around here - nothing specific, of some inaccuracies (I think some of this at least is some kind of resentment about how popular the site is though). I have noticed cases where information that only applies to IE was given without making it as clear as I would like to see that it only applied to IE.

jendelaniaga
07-24-2008, 11:08 AM
Hi again john.
Your reply was really encouraging!! Do you really think that I'm making progress by having this 'syntax error'? Hopefully you're right, John.
Ok, lets get to the business.:o I pasted the script once again in the site and the codes in the image of the letter "J" under 'PENGENALAN'. (Don't ask why I want to animate this letter yeah :rolleyes:).

Else, I can just animating the letters using gif's animator like how i did with the letter 'H' but the file is several times bigger than it's original. I'll be very thankful if you can make this script works, John.

Any help you would offer is very very much appreciated.
Thanks.

jscheuer1
07-24-2008, 02:25 PM
Replace:


<style>
.shakeimage{
position:relative
}
</style>
<script language='JavaScript1.2'>
<![CDATA[

/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
]]>
</script>


with (there are many changes, I think I've highlighted them all, just copy the below and replace the above on your page with it):


<style type="text/css">
.shakeimage{
position:relative
}
</style>
<script type="text/javascript">
<!--[CDATA[

/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
}
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
// ]]-->
</script>

It will make the J shake when you move your mouse over the J.

jendelaniaga
07-24-2008, 05:40 PM
Another warning sign onmouseover.
http://www.dynamicdrive.com/forums/images/icons/icon4.gif Object expected.

jscheuer1
07-24-2008, 06:13 PM
You killed all the line breaks in the script:


<style type='text/css'>
.shakeimage{
position:relative
}
</style>
<script type='text/javascript'>
<!--[CDATA[ /* Shake image script (onMouseover)- Dynamic Drive (www.dynamicdrive.com) For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com */ //configure shake degree (where larger # equals greater shake) var rector=3 ///////DONE EDITTING/////////// var stopit=0 var a=1 function init(which){ stopit=0 shake=which shake.style.left=0 shake.style.top=0 } function rattleimage(){ if ((!document.all&&!document.getElementById)||stopit==1) return if (a==1){ shake.style.top=parseInt(shake.style.top)+rector+'px'; } else if (a==2){ shake.style.left=parseInt(shake.style.left)+rector+'px'; } else if (a==3){ shake.style.top=parseInt(shake.style.top)-rector+'px'; } else{ shake.style.left=parseInt(shake.style.left)-rector+'px'; } if (a<4) a++ else a=1 setTimeout("rattleimage()",50) } function stoprattle(which){ stopit=1 which.style.left=0 which.style.top=0 } // ]]-->
</script>


Start over with what I actually posted, make sure your editor doesn't strip out the line breaks in the script.

jendelaniaga
07-24-2008, 07:45 PM
Sorry. It was purposely done since the original copy gave the same warning sign. forgot to replace it back with the one you provided.

jendelaniaga
07-24-2008, 07:55 PM
wait a sec. When i selected the view source, the line breaks dissappeared though I'm really sure to have copy paste exactly the same script you gave. hmm.. I should figure out why.

jendelaniaga
07-24-2008, 08:20 PM
Ok John. probably the error caused by the missing line breaks. I saved the view source data to a new html file, opened it in a new browser and paste your modified script into it and refreshed. Amazingly the letter J shaked!! I dunno why the line breaks dissappeared from the original site or how to repair it.

jscheuer1
07-24-2008, 09:11 PM
Fortunately, a script can be all one line if it is written to be that way. This version of the script (I'm not including the style, keep that as it was) should work regardless of line breaks:


<script type="text/javascript">
<!--[CDATA[

/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

/* configure shake degree (where larger # equals greater shake) */
var rector=3;

/* ///////DONE EDITTING/////////// */
var stopit=0;
var a=1;

function init(which){
stopit=0;
shake=which;
shake.style.left=0;
shake.style.top=0;
};

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return;
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
};
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
};
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
};
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
};
if (a<4)
a++;
else
a=1;
setTimeout("rattleimage()",50);
};

function stoprattle(which){
stopit=1;
which.style.left=0;
which.style.top=0;
};
// ]]-->
</script>

jendelaniaga
07-24-2008, 10:53 PM
Please, please, please do tell me if I've missed any part of your help http://smileys.smileycentral.com/cat/36/36_1_44.gif (http://plugin.smileycentral.com/http%253A%252F%252Fwww.smileycentral.com%252F%253Fpartner%253DZSzeb008%255FZRxdm699YYMY%2526i%253D36%252F36%255F1%255F44%2526feat%253Dprof/page.html)

jscheuer1
07-25-2008, 01:54 AM
Calm down. I'm not sure what the problem is with your editor. But I did overreach with my most recent solution. I'm sorry about that. As far as I can tell, you need to find a way to paste in the correct code without losing the line breaks (from post #11 in this thread):


<style type="text/css">
.shakeimage{
position:relative
}
</style>
<script type="text/javascript">
<!--[CDATA[

/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
}
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
// ]]-->
</script>

You might be able to make it an external file. But before we mess around with that, what editor are you using?

jendelaniaga
07-25-2008, 02:12 AM
I'm using blogger.com. not sure whether this answer your question.:confused:

jscheuer1
07-25-2008, 02:33 AM
Hmm, can you paste in:


<script type="text/javascript" src="image_shake.js"></script>
<!--
Shake image script (onMouseover)-
Copyright Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts,
visit http://dynamicdrive.com
-->

And then upload a separate file to the root of the domain called:

image_shake.js

which contains the following:


/*
Shake image script (onMouseover)-
Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
}
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

If you can do that, it should work. The only other thing I can think of is to ask your host why the line breaks are being removed.

Believe me, I'm at least almost as frustrated by this as you are. There may not be a way, though it seems to me that since you are able to paste other scripts in without losing the line breaks in them, that it should be possible.

jendelaniaga
07-25-2008, 08:50 AM
I will try uploading or maybe linking the .js to my blog since there is no way I can upload it to the domain roof. Will update the thread for any progress. Thousands thanks for your efforts over this matter. appreciate it!!http://smileys.smileycentral.com/cat/23/23_30_126.gif (http://plugin.smileycentral.com/http%253A%252F%252Fwww.smileycentral.com%252F%253Fpartner%253DZSzeb008%255FZRxdm699YYMY%2526i%253D23%252F23%255F30%255F126%2526feat%253Dprof/page.html)

jendelaniaga
07-26-2008, 01:16 AM
John,
I uploaded the image_shake.js file to a freehost site and link it to my blog.
but due to an xml error I changed this code;

<script type="text/javascript" src="image_shake.js"></script>
<!--
Shake image script (onMouseover)-
Copyright Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts,
visit http://dynamicdrive.com
-->

to this;

<script src='image_shake.js' type='text/javascript'/></script>
<!--
Shake image script (onMouseover)-
Copyright Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts,
visit http://dynamicdrive.com
-->

No warning sign at all during onmouseover but the image remains stiff. Do you think we need to do anything with the code within the J image itself to make this works?

P.S Seeked for a helping hand but failed

jscheuer1
07-26-2008, 03:19 AM
OK, the script is working! Now all you have to do is add the style back. Or you can just add this rule to any of your existing on page or linked stylesheets:


.shakeimage {
position:relative;
}

jendelaniaga
07-26-2008, 03:47 AM
It worked, John!! it's working!! http://smileys.smileycentral.com/cat/36/36_1_33.gif (http://plugin.smileycentral.com/http%253A%252F%252Fwww.smileycentral.com%252F%253Fpartner%253DZSzeb008%255FZRxdm699YYMY%2526i%253D36%252F36%255F1%255F33%2526feat%253Dprof/page.html)
I can never have this amazing script on my blog without your help, John. Thank you, John!!http://smileys.smileycentral.com/cat/23/23_28_125.gif (http://plugin.smileycentral.com/http%253A%252F%252Fwww.smileycentral.com%252F%253Fpartner%253DZSzeb008%255FZRxdm699YYMY%2526i%253D23%252F23%255F28%255F125%2526feat%253Dprof/page.html)

jscheuer1
07-26-2008, 05:01 AM
I'm so glad, congratulations!