XML and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ChefMo

    XML and javascript

    Any way to ruin javascript from inside of a .xml file?
    (<?xml-script...or the like)
  • Jeff North

    #2
    Re: XML and javascript

    On Mon, 21 Apr 2008 19:30:45 -0700 (PDT), in comp.lang.javas cript
    ChefMo <moshefromsinai @gmail.com>
    <bdd28bec-5f04-44b9-894a-f7c68c8e0b1c@59 g2000hsb.google groups.com>
    wrote:
    >| Any way to ruin javascript from inside of a .xml file?
    >| (<?xml-script...or the like)
    Alot of people can ruin javascript without the need for xml :-P

    But seriously, XML is data only therefore can not run scripts.
    -- -------------------------------------------------------------
    jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
    -- -------------------------------------------------------------

    Comment

    • Bart Van der Donck

      #3
      Re: XML and javascript

      ChefMo wrote:
      Any way to ruin javascript from inside of a .xml file?
      (<?xml-script...or the like)
      ---------------------------------
      XML:
      ---------------------------------

      <?xml version="1.0" encoding="UTF-8"?>
      <root>
      <jscode>alert(' Hi from XML');</jscode>
      </root>

      ---------------------------------
      javascript:
      ---------------------------------

      try {
      x = new ActiveXObject(' Microsoft.XMLDO M');
      }
      catch(e) {
      try {
      x = document.implem entation.create Document('', '', null);
      }
      catch(e) {
      alert(e.message );
      }
      }

      if (typeof(x) == 'object') {
      x.async = false;
      x.load('file.xm l');
      eval(x.getEleme ntsByTagName('j scode')[0].childNodes[0].nodeValue);
      }

      ---------------------------------

      Hope this helps,

      --
      Bart

      Comment

      • Martin Honnen

        #4
        Re: XML and javascript

        ChefMo wrote:
        Any way to ruin javascript from inside of a .xml file?
        (<?xml-script...or the like)
        Well there are XML formats like XHTML or SVG which have a script
        element. And with Mozilla or Opera you can put an XHTML script element
        into other XML formats, a simple example is
        http://home.arcor.de/martin.honnen/x...2008042202.xml.
        However you are much better off in directly using HTML or XHTML for the
        complete document, perhaps by transforming your XML to HTML or XHTML
        using XSLT.

        --

        Martin Honnen

        Comment

        Working...