473,770 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need to read xml content from a web service onto a local machine

5 New Member
i need to read xml content from a web service onto a local machine and parse the data using javascript.

While using XMLHttpRequest, it allows me to access xml content from anywhere on local machine. But i m not getting a clue as to how to access the content from a service
Any help appreciated
Jun 3 '10 #1
8 1840
Dormilich
8,658 Recognized Expert Moderator Expert
I recommend doing it server-side (more reliable than JavaScript), at least where fetching and basic processing is involved.
Jun 3 '10 #2
rohanit46
5 New Member
well i appreciate your recommendation, but my task is strictly to do it on client side using javascript!
Jun 3 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
just for clarification, the webservice and the website concerned are on the same server?
Jun 3 '10 #4
rohanit46
5 New Member
well the script is on local machine..and i need to access the xml content which is on a server..

i have tried to parse the xml content on the local machine using XMLHttpRequest object and i was successful. But It is not working while trying to access from web service
Jun 3 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
that’s due to the SOP (Same Origin Policy), a security mechanism for preventing XSS attacks.
Jun 3 '10 #6
rohanit46
5 New Member
so how do i over come it?
or what is the possible solution..?

my code is like this -

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <script type="text/javascript">
  5. var xmlDoc;
  6.  
  7. if(window.XMLHttpRequest){
  8.     xhttp = new XMLHttpRequest();
  9.     }
  10. else{
  11.     xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  12.     }
  13.  
  14. xhttp.open("GET","file:///C:/Documents%20and%20Settings/siddharthd/Desktop/javascript/xml/source.xml", false);
  15. xhttp.send("");
  16. xmlDoc=xhttp.responseXML;
  17.  
  18. var x = xmlDoc.getElementsByTagName("tag");
  19.  
  20. function display(){
  21.  
  22.     tagid = x[0].getElementsByTagName("tag_id")[0].childNodes[0].nodeValue;
  23.     longitude = x[0].getElementsByTagName("longitude")[0].childNodes[0].nodeValue;
  24.     latitude = x[0].getElementsByTagName("latitude")[0].childNodes[0].nodeValue;
  25.     altitude = x[0].getElementsByTagName("altitude")[0].childNodes[0].nodeValue;
  26.     dateadded = x[0].getElementsByTagName("date_added")[0].childNodes[0].nodeValue;
  27.     datemodified = x[0].getElementsByTagName("date_modified")[0].childNodes[0].nodeValue;
  28.     name = x[0].getElementsByTagName("name")[0].childNodes[0].nodeValue;
  29.     value = x[0].getElementsByTagName("value")[0].childNodes[0].nodeValue;
  30.  
  31.     txt="tag_id: " + tagid + "<br/>Longitude: " + longitude + "<br/>Latitude: " + latitude + "<br/>Altitude: " + altitude + "<br/>Date Added: " + dateadded + "<br/>Date Modified: " + datemodified + "<br/><br/>Name: " + name + "<br/>Value: " + value;
  32.     document.getElementById("showdata").innerHTML=txt;    
  33. }
  34. </script>
  35. </head>
  36.  
  37. <body onload="display()">
  38. <div id='showdata'></div>
  39. </body>
  40. </html>
  41.  
for a xml content which looks like this -

Expand|Select|Wrap|Line Numbers
  1. <tags>
  2. <tag>
  3. <tag_id>6</tag_id>
  4. <longitude>-97.721287186</longitude>
  5. <latitude>30.308577756</latitude>
  6. <altitude>189.752</altitude>
  7. <date_added>2010-05-24</date_added>
  8. <date_modified>2010-05-24</date_modified>
  9. <tag_data>
  10. <name_value>
  11. <name>id</name>
  12. <value>1</value>
  13. </name_value>
  14. </tag_data>
  15. </tag>
  16. </tags>
Jun 3 '10 #7
Dormilich
8,658 Recognized Expert Moderator Expert
I guess, you would have to lower your browser’s security settings, but that’s beyond my scope.

besides, you try to access a local file, which is (strictly speaking) forbidden in JavaScript (again for security reasons). in IE you may use an ActiveX control to do it.
Jun 3 '10 #8
rohanit46
5 New Member
ok thanks for your help!
Jun 3 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2697
by: Ian | last post by:
Can anyone help I have a web server on the internet with and ASP.NET application on it, the application is set to allow Anonymous Access and Integrated Windows. The Web.config is set to use Forms authentication. On the server side, where the web server is I have set IIS to disable Anonymous access and allow Integrated Windows. I have sync'd both the APSNET account on the web servers and application server so that access will be...
3
1208
by: John Holmes | last post by:
I've written an asp.net application on my local machine and would now like to continue to develop the application in a different location on our development web server on the intranet with all the debugging capabilities that I've had on my local machine. I was thinking I could do a save as at the project level, but haven't had luck with that. I tried creating a directory/virtual directory and copying the files but have had problems doing...
2
2393
by: David Hearn | last post by:
I have a webform that I am creating. I need for the user to be able to pass it the path and name of a file on his/her local machine without any interaction. I don't want to have to use the file upload control. This will be an automated process on their end. They should only have to type the url with a path/file name and let it upload the file that they specify (example: They type http://www.mysite.com?FileName=C:\Test\Test.txt and it will...
2
2449
by: Kishore Gopalan | last post by:
Hi, I need to write a windows application, where I have to list all the Web services on the local IIS. Is there any API or code I can use to get a list of all the Web Services on local machine. Thanks. Kishore
2
17711
by: ABCL | last post by:
Hi All, Can any one tell me that what is the difference between Network Service, Local Service and Local System ACcount for window services ABCL
4
4813
by: Abhi | last post by:
Hi All, I have a web service method which works fine when called from my local machine i.e. from localhost but when I publish the web services to a remote machine it throws an invalid cast soap exception. That web service method access Active Directory to get the group names for the given user. Following is the code. DirectorySearcher dirSearcher = new DirectorySearcher();
1
2162
by: moondaddy | last post by:
I have a test solution using .net 1.1 which is made up of a windows project and a web service project (all local). As I step through the code I want to step into the web service, however, the web executes but the debugger wont step into it. I have other solutions where I can step into the web service, but this one I can not. Using the configuration manager I set app projects to debug. can anyone tell me what I might be forgetting? ...
3
5814
by: ramesh.nrk | last post by:
Hi, Is there any way to read the cookies which are in local machine? Can we create cookies using windows Application in the local machine? I am developing a windows application which needs to Read the available cookies in the Local Machine, and it has to create cookies in the Local Machine.
0
2715
by: Bernie Hunt | last post by:
Is there a way to modify a registry key in HKey Local Machine? I have a number of programs that store data in the registry, but always in HKey Current User. Anyone know how to read and write HKey Local Machine? Thanks, Bernie
4
2139
by: supersav144 | last post by:
Hi there, i have a simple application which connects to a web service and then this web service creates a file on the machine which the application was accessed on... the problem i have though is that when i use the web service im not sure how i need to or the format to refer to the local machine (i.e do i use machine name, the IP address??) in order to save the file to this local machine. Any help would be much appreciated! Phil
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.