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

  • Home
  • SEARCH
  • 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 9145813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:36:25+00:00 2026-06-17T10:36:25+00:00

I need to parse XML parse with HTML and javascript. My XML: <tv_channel id

  • 0

I need to parse XML parse with HTML and javascript.

My XML:

 <tv_channel id = "1">
        <movie>
            <name>Movie 1</name>
            <time>6:00</time>
        </movie>
        <movie>
            <name>Movie 2</name>
            <time>6:30</time>
        </movie>
   </tv_channel>
    <tv_channel id = "2">
        <movie>
            <name>Movie 3</name>
            <time>11:15</time>
        </movie>
        <movie>
            <name>Movie 4</name>
            <time>13:45</time>
        </movie>
    </tv_channel>

and my Javascript is

function vyberZaner(zaner, nazov, from, to) {
    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", "XML.xml", false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    var txt = document.getElementById('div_table')
    var content = '';
    content += '<table border=\'1\'>';
    var x = xmlDoc.getElementsByTagName("tv_channel");
    content += '<h1 > ' + nazov + ' </h1>';
    content += ("<td> NAME </td>");
    content += ("<td> GENRE </td>");
        for (i = 0; i < x.length; i++) {
            content += '<tr><td>';
            content += x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
            content += '</td><td>';
            content += x[i].getElementsByTagName("time")[0].childNodes[0].nodeValue;
            content += '</td></tr>';
}
    content += '</table>';
    txt.innerHTML = content;
}

And the output is

Movie 1   6:00
Movie 2   6:00
Movie 3   6:00
Movie 4   6:00

and I need just two

Movie 1   6:00
Movie 2   6:00

or

Movie 3   6:00
Movie 4   6:00

It depends on id but I don’t know how to do that.
I need just to get output like only “Movie 1 and Movie 2” or “Movie 3 and Movie 4”. The user will choose with button to select xml and display only the channel’s info with id 1 or id 2 like and their name and time.

  • 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-17T10:36:27+00:00Added an answer on June 17, 2026 at 10:36 am

    Use the getAttribute method to determine whether to pull the XML for channel id 1 or channel id 2, and then output that content. Inside the for loop, use:

    if(x[i].getAttribute(‘id’) == 1or2) {do whatever}

    See: http://www.w3schools.com/dom/met_element_getattribute.asp

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

Sidebar

Related Questions

I need to parse a value from an xml and place it to image's
I need to parse a XML String so I can use some of the
I don't need to parse the XML, or to decode it into an ActionScript
i need to parse this php xml response in android: <?phpxml version=1.0 encoding=utf-8?> <SmsResponse>
I need to parse a bunch of incoming xml documents, they all have the
I need to parse a continuous stream of well-formed XML elements, to which I
I have an XML file which I need to parse using PHP and send
Given the XML below, I need to parse it and output names of all
I'm using R with the xml package to parse data stored in html files.
First things first. I know how to parse XML/HTML with simplexml, and I know

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.