We help IT Professionals succeed at work.
Get Started

i would like to access xml node values via javascript but i get  error

Last Modified: 2015-06-13
hi i have an xml , and just want to access test value below via javascript,

but it fails to display the value ,below is my page , could you help me what i am missing here?

<?xml version="1.0" encoding="utf-8" ?>

  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LongPoll.aspx.cs" Inherits="LongPollingSample.LongPoll" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
     <script src="https://code.jquery.com/jquery-1.10.2.js"></script>


            type: "GET",
            url: "Data.xml",
            dataType: "xml",
            success: function (xml) {
                // Parse the xml file and get data
                var xmlDoc = $.parseXML(xml),
                    $xml = $(xmlDoc);

                $v1 = $xml.find("test");


//$xml.find('note').each(function () {
                //    $("#test").append($(this).text() + "<br />");

        //var intervalId = setInterval(function () {

        //    $.ajax({
        //        url: "server", success: function (data) {
        //            //Update your dashboard gauge
        //            //salesGauge.setValue(data.value);
        //        }, dataType: "json"
        //    });
        //}, 30000);

    <form id="form1" runat="server">
    <p id="someElement"></p>

Open in new window

Watch Question
Most Valuable Expert 2017
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE