Avatar of nicedone
nicedone
 asked on

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

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" ?>
<test>3</test>



  <%@ 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">
    <title></title>
    
     <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
   

    <script>

        $.ajax({
            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");


                alert($xml.find("test").value);

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

    </script>
    <script>
        
        //var intervalId = setInterval(function () {


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

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p id="someElement"></p>
    </div>
    </form>
</body>
</html>

Open in new window

JavaScriptjQuery.NET Programming

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nicedone

ASKER
thanks
Julian Hansen

You are welcome.
Your help has saved me hundreds of hours of internet surfing.
fblack61