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 8186037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:03:41+00:00 2026-06-07T02:03:41+00:00

I am new to XML coding and I am working on a site right

  • 0

I am new to XML coding and I am working on a site right now to help me improve on the skill. I think i got all the syntax right for the page but it seems not to be working. Here’s the code for the index page and also the xml file I am trying to make use of.

<html>
<body>

<script type="text/javascript">
var link= "http://api.remix.bestbuy.com/v1/stores(area(55423,10))+products(name=playstation*)?show=storeId,name,products.sku,products.name&page=1&apiKey=ydpyq9h9cmpmzaakbawv9mzk";
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","test.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
document.write("<table border='1'>");
var x = xmlDoc.getElementsByTagName("name");
for (i=0;i<5;i++)
  { 
  document.write("<tr><td>"); 
  document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
   document.write("Step 2");
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("distance")[0].childNodes[0].nodeValue);
  document.write("</td></tr>");
  }
document.write("</table>");
</script>

</body>
</html>

and the XML i got off a sample best buy request

<stores warnings="Distances are in terms of miles (default). Your product criteria matches too many records. That exceeds number of records that we allow on the product side of a store-product query. We've automatically truncated the products down to the first 100. These results are not complete. Avoid this by narrowing the number of products in your query." currentPage="1" totalPages="1" from="1" to="10" total="10" queryTime="0.015" totalTime="0.153" canonicalUrl="/v1/stores(area("55423",10))+products(name="playstation*")?show=storeId,name,products.sku,products.name&apiKey=ydpyq9h9cmpmzaakbawv9mzk" partial="false">
  <store>
    <storeId>281</storeId>
    <name>Richfield</name>
    <products>
      <product>
        <sku>9984133</sku>
        <name>Assassin's Creed Brotherhood - PlayStation 3</name>
      </product>
      <product>
        <sku>7917141</sku>
        <name>Assassin's Creed Greatest Hits - PlayStation 3</name>
      </product>
      <product>
        <sku>2613621</sku>
        <name>Assassin's Creed: Revelations - PlayStation 3</name>
      </product>
      <product>
        <sku>3109269</sku>
        <name>Assassin's Creed: Revelations Collector's Edition (Game Guide) - Xbox 360, PlayStation 3, Windows</name>
      </product>
      <product>
        <sku>3109065</sku>
        <name>Assassin's Creed: Revelations The Complete Official Guide (Game Guide) - Xbox 360, PlayStation 3, Windows</name>
      </product>
      <product>
        <sku>9927337</sku>
        <name>Batman: Arkham Asylum Game of the Year Edition - PlayStation 3</name>
      </product>
      <product>
        <sku>3116162</sku>
        <name>Batman: Arkham City (Signature Series Game Guide) - Windows, PlayStation 3, Xbox 360</name>
      </product>
      <product>
        <sku>5260722</sku>
        <name>Batman: Arkham City - Game of the Year Edition - PlayStation 3</name>
      </product>
      <product>
        <sku>2173056</sku>
        <name>Batman: Arkham City - PlayStation 3</name>
      </product>
      <product>
        <sku>3550073</sku>
        <name>Battlefield 3 (Game Guide) - Xbox 360, PlayStation 3, Windows</name>
      </product>
</products>
  </store>
</stores>
  • 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-07T02:03:43+00:00Added an answer on June 7, 2026 at 2:03 am

    You will have to put the code that executes after the data is loaded in the onreadystatechange event of the xmlhttp object: http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp

    xmlhttp.onreadystatechange = function() {
        if (httprequest.readyState == 4) {
            // Response finished
            if (httprequest.status = 200) {
               // everything OK
               // Parse the data
            } else {
               // Something gone wrong with the request
            }
        }
    }
    

    Edit:
    Looking at your code now I realized that you are using var x = xmlDoc.getElementsByTagName("name");. This will select EVERY tag name, including the inner one. Try using store to get each one instead of the name and then look for product.

    Also, you are using a hard coded limit in the for loop. Use x.length instead: for (var i=0; i<x.length;i++)

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

Sidebar

Related Questions

I'm new to querying XML datatype in SQL Server 2005. Anyone can help me
I am new to NHibernate/FluentNHibernate. I use FNH for my coding now as I
I'm new to coding. I'm trying new things to learn better coding techniques. Right
I'm new to php and web coding so any help would be great. I'm
I've created a new .xml file in my layout folder called log.xml . It
I'm creating a new XML File out of a table. The problem is I
still new to XML parsing with the iphone so i have a few questions.
I am new to xml and android programming.Here is my xml code... I don't
I'm new in xml, sorry for the dumb question. I'm trying to create xsl
I'm new to XML validation using .xsd files. Maybe I'm not even asking the

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.