dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: I need help to get data from xml file using javascript

  1. #1
    Join Date
    Jul 2014
    Posts
    2

    I need help to get data from xml file using javascript

    Hi everyone.
    I'm begginer in Javascript language and i need help.I'm trying to get data from web page thats actually xml file using javascript.I'm learining this and i already did example when you download xml file and have file on computer and than to extract data and i complete this, but now i need someone to help me and show me on example how to get data from xml file which is on web page and show results in new window,
    Hope somebody will help me with this and help me in my learning Javascript.

    Thanks everybody in advance.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,964
    AJAX has a method of accessing XML

    https://developer.mozilla.org/en-US/...erializing_XML

    http://www.javascriptkit.com/dhtmltu...getpost3.shtml

    Might get you going to where you want to get to...
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Jul 2014
    Posts
    2
    Thank you for your reply ....
    I'm actually having a problem to access data on Bing Search Api which is actually xml file and try to get some elements from that page.
    When i send XMLHttpRequest i getting null and also error about Cross Origin...It actually work when i save file on my computer as xml file and than i'm able to extract data from that file ... but when i try this way online than i'm getting errors...if someone had similar problem and if someone know how to do that please let me know and help me with that ...
    Thanks in advance.

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,964
    You would have a problem with getting data via AJAX like that because of something called "Same Origin Policy" as AJAX only works on the domain which served the page.

    I would suggest that you do the legwork server-side and grab the data with a cURL request, use the functionality of PHP's built in functions to process your XML and then package the data for your AJAX to collect for your page to display.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles