473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML and javascript

Any way to ruin javascript from inside of a .xml file?
(<?xml-script...or the like)
Jun 27 '08 #1
3 957
On Mon, 21 Apr 2008 19:30:45 -0700 (PDT), in comp.lang.javascript
ChefMo <mo************@gmail.com>
<bd**********************************@59g2000hsb.g ooglegroups.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.
-- -------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Jun 27 '08 #2
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
Jun 27 '08 #3
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/
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.