Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:22:41+00:00 2026-06-10T05:22:41+00:00

Can anyone tell me or provide a full (but simple) example on how to

  • 0

Can anyone tell me or provide a full (but simple) example on how to get the value of an XML node and plot (output) it into a specific HTML element.

I have spent hours trying to look this up, but nothing works for me or examples are incomplete.

Also, note that I neither require nor desire use of the “.each” method or any loops. I just want to singularly grab one node value and put it into one html element, however I would love to have an example of what is in both files (xml and javascript), as well as how to open the xml document. I have seen examples of opening the xml document, but they are different from eachother so there is no way for me to know which one actually works.

I have also done some testing on this, but can’t seem to get it to plot anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:22:42+00:00Added an answer on June 10, 2026 at 5:22 am

    Main thing you need to understand is how the DOM works. If you do not know how the DOM works, you can find some info here

    In essence you’re dealing with parent tags and children tags. With XML, you need to extract that information and from there you can do whatever you like.

    If you go here to the left handside bar there are lots of examples and tutorials on how to manipulate XML DOM nodes

    Here are just a couple things to know though (my professor taught me this and they’re useful tips)

    1. You can’t use ids or classes. Instead you should be getting the XML nodes with

      var elements = node.getElementsByTagName("tagname");

    2. You can’t use innerHTML to get the text inside a node. You could in HTML, but not for XML. For that you have to use

      var text = node.firstChild.nodeValue;

    3. You can’t use .attributeName to get an Attribute. You need to use

      var attrValue = node.getAttribute("attrName");

    Hope this helps. If you’re still struggling, just ask.

    Alright well I’ve been trying to work with the examples on w3schools and I hope this helps. If it doesn’t just ask:

    Go to this example

    I’m going to try to walkthrough this example but you should be getting a general idea of what’s going on. They have an XML file known as cd_catalog.xml with all the information they need. When they press the button it simply displays all that information in an HTML format. If you look at the HTML code before and after you can see that the myDiv gets populated with all the artists in the xml file.

    Now let’s look at the code.

    function loadXMLDoc()
    {
    var xmlhttp;
    var txt,x,i;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        xmlDoc=xmlhttp.responseXML;
        txt="";
        x=xmlDoc.getElementsByTagName("ARTIST");
        for (i=0;i<x.length;i++)
          {
          txt=txt + x[i].childNodes[0].nodeValue + "<br />";
          }
        document.getElementById("myDiv").innerHTML=txt;
        }
      }
    xmlhttp.open("GET","cd_catalog.xml",true);
    xmlhttp.send();
    }
    

    Some key things to point out. Step-by-step they have a function so when the document is fully loaded, and the code has been sent (this is checked by xmlhttp.status==200) he’s going to pull all the xml data from cd_catalog.xml and store it into xmlDoc by getting the xmlhttp.responseXML

    So now xmlDoc has all the information from cd_catalog.xml stored in a convenient variable. From there, he uses xmlDoc.getElementsByTagName("ARTIST"); to get an array of ALL the artists in the xml file and nothing else. He names this array x.

    Now he goes through this giant array known as x and for each index i (represented as x[i]) he gets the childNodes which returns an array with only one thing inside it (the text) which is why he refers to childNodes[0] index and he gets the .nodeValue of it. So NOW he has the text that was originally stored in the xml file in a variable called txt and he simply adds a </br> tag and whatever else HTML he wants and puts it via document.getElementById("myDiv").innerHTML so that it is translated into HTML format. This process repeats for each ARTIST tag in the xml file.

    I hope this helps. If you’re still confused, let us know. And this does require you to know the xml file you’re handling and where it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me why the following code fails to submit the form into
Can anyone please tell me how I can get the jQuery Validator to call
Can anyone tell me why this code would not be working? $('body').on('test', function() {
can anyone tell me how to select data by date in MS.ACCESS database using
Can anyone tell me how I can correctly pass my application context to my
Can anyone tell me how to identify a particular background process (i.e., Already running
Can anyone tell why my jQuery script is not loading here <?php wp_enqueue_script(jquery); ?>
Can anyone tell me, how to make shadow, using UIPageViewController, around of my background
Can anyone tell me how to substring a GridView BoundField object please? I tried
Can anyone tell me if I can (in the command line) issue a POST

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.