Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > XML and javascript

Reply
Thread Tools

XML and javascript

 
 
ChefMo
Guest
Posts: n/a
 
      04-22-2008
Any way to ruin javascript from inside of a .xml file?
(<?xml-script...> or the like)
 
Reply With Quote
 
 
 
 
Jeff North
Guest
Posts: n/a
 
      04-22-2008
On Mon, 21 Apr 2008 19:30:45 -0700 (PDT), in comp.lang.javascript
ChefMo <(E-Mail Removed)>
<(E-Mail Removed)>
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

But seriously, XML is data only therefore can not run scripts.
-- -------------------------------------------------------------
http://www.velocityreviews.com/forums/(E-Mail Removed) : Remove your pants to reply
-- -------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      04-22-2008
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.XMLDOM');
}
catch(e) {
try {
x = document.implementation.createDocument('', '', null);
}
catch(e) {
alert(e.message);
}
}

if (typeof(x) == 'object') {
x.async = false;
x.load('file.xml');
eval(x.getElementsByTagName('jscode')[0].childNodes[0].nodeValue);
}

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

Hope this helps,

--
Bart
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      04-22-2008
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
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User uploads XML, page reads XML and adjusts settings all in javascript edfialk Javascript 2 08-03-2007 09:52 PM
Working with XML in JavaScript / XML Javascript'? noff Javascript 0 06-14-2007 12:46 PM
[Announce] Stylus Studio 2007 XML Enterprise Suite Released: XML Pipeline, XML Publishing and Data Conversion API's stylusstudio@gmail.com Java 0 09-26-2006 05:04 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
What XML technologies to learn first for "XML Processing" and "XML Mapping"? Bomb Diggy Java 0 07-28-2004 07:26 AM



Advertisments