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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:19:32+00:00 2026-05-19T03:19:32+00:00

I am retrieving HTML from a remote host with the following jQuery code var

  • 0

I am retrieving HTML from a remote host with the following jQuery code

    var loadUrl = "URL.html"; 
        $("#result")
        .html(ajax_load)
        .load(loadUrl + " table.schedule");

Which gives me the following HTML

<table class="schedule">
        <tr>
                <th>Name</th>
                <th>column A</th>
                <th>column B</th>
        </tr>
        <tr>
                <td>1</td>
                <td>A1</td>
                <td>B1</td>
        </tr>
        <tr>
        <tr>
                <td>2</td>
                <td>A2</td>
                <td>B2</td>
        </tr>
</table>
<table class="schedule">
        <tr>
                <th>Name</th>
                <th>column C</th>
                <th>column D</th>
        </tr>
        <tr>
                <td>3</td>
                <td>C1</td>
                <td>D1</td>
        </tr>
        <tr>
        <tr>
                <td>4</td>
                <td>C2</td>
                <td>D2</td>
        </tr>
</table>

The number of TR & TDs can change, and I want to retrieve the data for column A,B,C,D and “transform” the HTML into a list format like the following XML.

<schedule name="1">
        <data>A1</data>
        <data>A2</data>
</schedule>
<schedule name="2">
        <data>B1</data>
        <data>B2</data>
</schedule>
<schedule name="3">
        <data>C1</data>
        <data>C2</data>
</schedule>
<schedule name="4">
        <data>D1</data>
        <data>D2</data>
</schedule>

I have tried the following code, which provides me with the first column data, but it also concatenates all the TDs from both Tables into one list.

$("#load_get").click(function(){
var xml = "<schedule>";
$("#result")
.find("tr").each(function() {
xml += "<data>";
xml += $(this).find("td").eq(1).html() + "\n";  
xml += "</data>";
} );
xml += "</schedule>";
alert(xml);
});

Please help.

EDIT

Thank you Polarblau, Federic & Albert for your responses. They helped a lot, sorry to change the goal, but if i could modify the scenario slightly.

This is the same HTML, except it has a header in the first TR, there are two tables and the first column is ignored as before.

<table class="schedule">
        <tr>
                <th>ignore</th>
                <th>Header1</th>
                <th>header2</th>
        </tr>
        <tr>
                <td>ignore</td>
                <td>A1</td>
                <td>B1</td>
        </tr>
        <tr>
                <td>ignore</td>
                <td>A2</td>
                <td>B2</td>
        </tr>
</table>

//second table

The XML i wish to have, needs to grab the Header(TH) and use it in the TD loop to set the name attribute, like so.

<schedule name="Header1">
        <data>A1</data>
        <data>A2</data>
</schedule>
<schedule name="Header2">
        <data>B1</data>
        <data>B2</data>
</schedule>

//second table xml

I tried unsuccessfully, to modify your solutions to achieve this.

  • 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-19T03:19:33+00:00Added an answer on May 19, 2026 at 3:19 am

    If I understand your question correctly, you need to create the <schedule> elements inside your loop:

    $("#load_get").click(function() {
        var xml = "";
        $("#result tr").each(function() {
            var cells = $("td", this);
            if (cells.length > 0) {
                xml += "<schedule name='" + cells.eq(0).text() + "'>\n";
                for (var i = 1; i < cells.length; ++i) {
                    xml += "\t<data>" + cells.eq(i).text() + "</data>\n";
                }
                xml += "</schedule>\n";
            }
        });
        window.alert(xml);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am retrieving the HTML source code from a remote URL via C#. I
I am retrieving data from a SQL table so I can display the result
I have the following code on the client side for retrieving data from the
Suppose I am retrieving a url as follows: string url = http://www.somesite.com/somepage.html HttpWebRequest req
I'm retrieving data from a MySQL table and displaying it on a webpage using
I am retrieving an html document from a MySQL db through PHP, and it
I am developing an HTML/Javascript/JQuery page retrieving a JSON returned by a PHP script:
I'm retrieving an array of objects from a hidden html input field. The string
My code is retrieving player names from a database and outputting them into a
I'm creating multiple form retrieving data from jquery. after that i want to work

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.