News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How to integrate JavaScript with *.xml file?

Started by Grek.Kamchatka, February 26, 2006, 03:43:59 AM

Previous topic - Next topic

Grek.Kamchatka

Hi all.
I must open one file in Source dir, find the string and add some data after founded string. But one problem... i try to add javascript
  else
        {
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]]></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }
}


]]></add>
but it doesn't work because of two ]]>. The script is blocked after first closed brackets. What should i do, to fix this problem???

Dannii

You're using this in an SMF mod or something else? That whole thing is CDATA in another xml file?
You'll have to echo php escape characters for the first ]]>, or do something like echo ']' , ']>';
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Grek.Kamchatka

Yep...i made an SMF mod, that used an xml file. When i founded needed data, i use
<add><![CDATA[ tag. BUT, now i can't add JavaScript, because it begin with this tag too =(
4example:
I have this:

// JavaScript as a last resort.
        else
        {
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]]></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }


I'm doing this request:

<add><![CDATA[
// JavaScript as a last resort.
        else
        {
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]]></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }
]]></add>

You see?
<![CDATA[ <![CDATA[ ]]> ]]>

Dannii

<add><![CDATA[
// JavaScript as a last resort.
        else
        {
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <title>...</title>
                <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                        history.go(-1);
                // ]' , ']></script>
        </head>
        <body>&laquo;</body>
</html>';

                obExit(false);
        }
]]></add>
Should work fine.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Grek.Kamchatka

Quote from: eldacar on February 26, 2006, 06:45:11 AM
Should work fine.
Thank you very much eldacar. I'll try it tomorrow.

P.S. I think it is mistake in your profile. In url adress i see your site like http://ftgforums.com but actually it link to the http://ftgcommunity without any site =)

Dannii

:O I must have mixed up the profile fields lol!
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Advertisement: