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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:11:21+00:00 2026-05-29T08:11:21+00:00

When I use responseText, I get all the data. From <HTML> to </HTML> .

  • 0

When I use responseText, I get all the data. From <HTML> to </HTML>. How to I extract specific parts of it? For example, I have this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Tester</title>
    </head>

    <body>

        <table>
            <tr>
                <td><a name="Name"></a>Name</td>
                <td>John</td>
            </tr>
            <tr>
                <td><a name="Email"></a>Email</td>
                <td>john@aol.com</td>
            </tr>
            <tr>
                <td><a name="Address"></a>Address</td>
                <td>123 Elm Street</td>
            </tr>
            <tr>
                <td><a name="City"></a>City</td>
                <td>Los Angeles</td>
            </tr>
            <tr>
                <td><a name="State"></a>State</td>
                <td>CA</td>
            </tr>
        </table>

    </body>
</html>

And Then I need to just extract like the city part Los Angeles. How would I go about doing this? I can’t do responseText.getElementByTagName, or anything like that.

Here’s the AJAX call:

var xmlhttp;
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)
    {
    var pageContents = xmlhttp.responseText;
    document.getElementById("myDiv").innerText = pageContents;

    }
  }
xmlhttp.open("GET","content.html",false);
xmlhttp.send();
  • 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-05-29T08:11:22+00:00Added an answer on May 29, 2026 at 8:11 am

    For a pure JavaScript solution, try (untested):

    var city = responseXML.getElementsByName('City').parentNode.nextElementSibling.childNodes[0].getAttribute('textContent');
    

    That said, a JavaScript library, like jQuery, to do the heavy lifting sure makes your code a lot easier to read (as well as cross-browser friendly).

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

Sidebar

Related Questions

I have refactored working code to use proper objects and now I can't get
We use a data acquisition card to take readings from a device that increases
I use this code to load a htmlbox-instance to my page (this page also
Okay, this should be really simple, but I have searched all over for the
use this website a lot but first time posting. My program creates a number
I have no working knowledge of Java script and am trying to get into
i have problem when i want to get id in li element and stored
I have a page. In that page's header i have all of my javascript.
I find this excellent code, posted by aemkei as answers to this questions: How
I'm using this xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(picHint).innerHTML=xmlhttp.responseText; } } xmlhttp.open(GET,getpic.php?q=+str+&t=

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.