Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 26th, 2005, 01:31 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access is denied" load a simple xml file

Hi there,

Javascript will give me a pop-up error "Access is denied" when i try to load a simple xml file, which is in the server machine itself. The script is within a JSP page. I am running it with IE6 from an windows administrative acc straight on the server so there shouldn't be any access prob.

Code is something like that:

<script language="javascript>
var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.load("C:/Documents and Settings/test.xml)

// upon the load statement; javascript will prompt error and jsp dies off

</script>

Another question i wanna ask, can i run the xml file at client side using the same javascript coding like above?

Hope u guys can help me.
Thanks in advance.

Reply With Quote
  #2 (permalink)  
Old January 26th, 2005, 05:13 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You are trying to access a local file which will only be allowed if the site is in "Trusted Sites" or "Local Intranet" and you allow scripting of activex not marked safe.

The fact that the client is also the server is irrelevant.

The code would also work in a standard set up provided the same security settings were applied.


--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old February 17th, 2005, 02:00 AM
Registered User
 
Join Date: Feb 2005
Location: chennai, tamilnadu, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually i too have encountered a very similar problem. I had to use a round about way to cater the "Access Denied".

In Xmldom activex there are two functions to load xml

1) Load method to load a xml from a file, the string passed as a parameter is a filename along with path

2) LoadXML method to load a xml data directly by storing in string

The first method gives the "Access denied" problem so i tried to use the second method which did work

The javascript code is as follows, as you are already using an activex control i think you can use one more in teh same code FSO - File System Object

<script language="javascript>

var fsoXML = new ActiveXObject("Scripting.FileSystemObject");
var XMLFile = fsoXML.OpenTextFile(("C:/Documents and Settings/test.xml",1);
var Data = XMLFile.ReadAll();
XMLFile.Close();

var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(Data);

// upon the load statement; javascript will prompt error and jsp dies off

</script>


Please check the code, it will surely work


Valli
Reply With Quote
  #4 (permalink)  
Old February 24th, 2005, 11:22 AM
Authorized User
 
Join Date: Feb 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i had a very similar problem in writing the xml file from asp.net application,This is happenning because of locking the system while writing the xml file in the drive.To Overcome that just create a folder and and place the file hence with.....

Reply With Quote
  #5 (permalink)  
Old January 7th, 2006, 09:03 AM
Registered User
 
Join Date: Jan 2006
Location: iasi, , Romania.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello!
that code doesn't work
do you have a solution for mozilla?

Reply With Quote
  #6 (permalink)  
Old January 25th, 2006, 03:10 AM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Kalpakavalli.S
it is not working even that it is giving me error of javascript that "object expect" i think due to

var fsoXML = new ActiveXObject("Scripting.FileSystemObject");


<script language="javascript>

var fsoXML = new ActiveXObject("Scripting.FileSystemObject");
var XMLFile = fsoXML.OpenTextFile(("C:/Documents and Settings/test.xml",1);
var Data = XMLFile.ReadAll();
XMLFile.Close();

var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(Data);

give some nice solution here.


Reply With Quote
  #7 (permalink)  
Old May 17th, 2006, 05:00 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've had a similar problem occur - however it is not consistent...

Originally I had some structured JS code that worked fine (loading xml docs from localhost and from external sites).

Then I updated most of the code to be more OO - except the xml loading code. And now it only loads xml files on localhost. When attempting to load anything external and I get an "Access is denied" error.

Any ideas why?

All the code that does the load and retrieval of values from the xml files has not changed - and it works when calling it from very basic structured JS - eg poplist() (where poplist is a function that does the load and populates a list with the data in the xml file).

However when I call it from my new objects it can load local xml files - just not external ones.

Any help will be very much appreciated!
Thanks in advance
Tim Huffam

Reply With Quote
  #8 (permalink)  
Old May 24th, 2006, 05:18 AM
Registered User
 
Join Date: May 2005
Location: FARIDABAD, HARYANA, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi friends
I 've also faced the same prob..
Wat i did, just trying to fetch an xml file from external source, it was giving me the Javascript error "Access is denied".
The solution of the above Problem is

Just change ur Browser Internet settings
if u are using IE then
click on Tools -> Options -> Security -> Custom Level -> Micsellaneous ->Access Data Sources across Domains -> Prompt.

Then click on "OK" ..


and refresh page and try again....

I hope it will run

Reply With Quote
  #9 (permalink)  
Old June 19th, 2007, 10:22 AM
Registered User
 
Join Date: Jun 2007
Location: Worthington, MN, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Just change ur Browser Internet settings
if u are using IE then
click on Tools -> Options -> Security -> Custom Level -> Micsellaneous ->Access Data Sources across Domains -> Prompt.

Then click on "OK" ..
That's all fine and dandy, works like you said it would. However, I'm trying to embed an rss feed into my site for my users to view. I can't expect every single one of them to go and modify their IE security settings.

There's gotta be a way to "Access data sources across domains" via the script...right?

Any ideas?

Benny_A
----------
Are you not entertAIn3d?
Reply With Quote
  #10 (permalink)  
Old June 19th, 2007, 10:37 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The only way is to use a server-side proxy that relays the requests from your server to the real server. Cross domain access is only forbidden on the client, servers have free reign.

--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access denied, can't create xml file from ASP.NET goldablasha C# 3 February 27th, 2007 05:50 AM
How to load an xml file that is in same project? tryston02 C# 2005 1 November 28th, 2006 02:50 PM
Getting VB.NET to load & update XML file kyma XML 0 March 19th, 2005 04:58 PM
access denied when uploading file daliaca BOOK: ASP.NET Website Programming Problem-Design-Solution 1 January 16th, 2005 11:08 AM
LOAD A XML FILE FROM JAVASCRIPT nen Javascript How-To 1 December 20th, 2004 11:03 AM



All times are GMT -4. The time now is 12:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.