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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:45:30+00:00 2026-05-27T02:45:30+00:00

I am working on a simple movie database to practise my JavaScript and have

  • 0

I am working on a simple movie database to practise my JavaScript and have encountered difficulty extracting information from the xml file. Let me explain my scenario. Sorry if it gets a bit long-winded!

The interface I have created has three columns which each serve the following functions:

Column 1 -> The user selects a film of their choice.

Column 2 -> Once the user has selected a film in Column 1 then more information about the film appears in this column. This includes title, director and cast. The user has the option of then selecting a cast member to find out information about them.

Column 3 -> Once the user has selected a cast member in Column 2 then their name and a picture of them appears in this column (using the tag). This information in this column also includes the film title, film artwork (applied tag).

But the difficulty I have encountered is as follows – I have a rough idea of how to update column 2 in real time to reflect the changes in Column 1.

The method I am using for acquiring the relevant information in Column 2 is creating an array then using the indexOf to retrieve a the details of a specific film. I know this method is wrong and it would be better to pull the relevant information from the xml file.

How do I use the idx from the Column 1 selection to pull out the relevant information to put in Column 2 and 3?

Here is what I’ve done so far:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function XMLload() {
    jQuery.post(url, function(data) {getxml(data)}, 'xml');
}

function dataFromTag(node, t) {
    var d = node.getElementsByTagName(t);
    if (d.length == 0) return ('');
    return (d[0].firstChild.nodeValue);
}

jQuery(document).ready(XMLload);

var url = 'movie.xml';

var xmlMovies;
var aryMovieList = [];
var xmlActors;
var aryActors = [];
var iframeOpen = '<html><head><\/head><body>'
var iframeClose = '<\/select><\/form><\/body><\/html>'

function getxml(xmldoc) {
    xmlMovies = xmldoc.getElementsByTagName('movie');
    var hstr = iframeOpen;
    hstr += '<select size="' + xmlMovies.length + '" onchange="parent.actors(this.selectedIndex);">';
    for (var MovieID = 0; MovieID < xmlMovies.length; MovieID++) {
        aryMovieList[aryMovieList.length] = dataFromTag(xmlMovies[MovieID], "title");   
        xmlActors = xmlMovies[MovieID].getElementsByTagName("actor");

        for (var ActorID = 0; ActorID < xmlActors.length; ActorID++) {
            aryActors[aryActors.length] = dataFromTag(xmlMovies[MovieID], "director") + "/" + dataFromTag(xmlMovies[MovieID], "title") + "/" + dataFromTag(xmlActors[ActorID], "name");
        }

        hstr += '<option>' + aryMovieList[MovieID] + '<\/option>';
    }
    hstr += iframeClose;

    // test for aryMovieList
    // alert(aryMovieList);
    // test for aryActors
    // alert(aryActors);

    with(document.getElementById('movies').contentDocument) {
        open();
        write(hstr);
        close();
    }
}

function actors(idx) {  
    var hstr = iframeOpen;
    var selectActor = [];
    hstr += 'title: ' + dataFromTag(xmlMovies[idx], 'title');
    hstr += '<br>';
    hstr += 'director: ' + dataFromTag(xmlMovies[idx], 'director');
    hstr += '<br>';

    for (var i = 0; i < aryActors.length; i++) {
        var aryActorList = aryActors[i].indexOf(dataFromTag(xmlMovies[idx], 'director') + '/' + dataFromTag(xmlMovies[idx], 'title'));
        if (aryActorList >= 0) {
            selectActor[selectActor.length] = i;
        }
    }

    // alert(selectActor);

    hstr += '<select size="' + selectActor.length + '" onchange="parent.info(this.selectedIndex);">';

    for (var i = 0; i < aryActors.length; i++) {
        var aryActorList = aryActors[i].indexOf(dataFromTag(xmlMovies[idx], 'director') + '/' + dataFromTag(xmlMovies[idx], 'title'));
        if (aryActorList >= 0) {
            hstr += '<option>' + aryActors[i].substring(aryActors[i].lastIndexOf("/") + 1) + '<\/option>';
        }
    }

    hstr += iframeClose;

    with(document.getElementById('actors').contentDocument) {
        open();
        write(hstr);
        close();
    }
}

function info(idx) {
    var hstr = iframeOpen;
    hstr += '';
    hstr += iframeClose;

    with(document.getElementById('info').contentDocument) {
        open();
        write(hstr);
        close();
    }
}
</script>

movie.xml

<movies>
    <movie>
        <title>Match Point</title>
        <director>Woody Allen</director>
        <image>Match-Point.jpg</image>
        <actor>
            <name>Scarlett Johansson</name>
            <image>Scarlett-Johansson.jpg</image>
        </actor>
        <actor>
            <name>Brian Cox</name>
            <image>Brian-Cox.jpg</image>
        </actor>
        <actor>
            <name>Matthew Goode</name>
            <image>Matthew-Goode.jpg</image>
        </actor>
        <actor>
            <name>Penelope Wilton</name>
            <image>Penelope-Wilton.jpg</image>
        </actor>
    </movie>
    <movie>
       <title>Inception</title>
        <director>Christopher Nolan</director>
        <artwork>Inception.jpg</artwork>
        <actor>
            <name>Leonardo DiCaprio</name>
            <image>Leonardo-DiCaprio.jpg</image>
        </actor>
        <actor>
            <name>Ken Watanabe</name>
            <image>Ken-Watanabe.jpg</image>
        </actor>
        <actor>
            <name>Joseph Gordon-Levitt</name>
            <image>Joseph-Gordon-Levitt.jpg</image>
        </actor>
        <actor>
            <name>Marion Cotillard</name>
            <image>Marion-Cotillard.jpg</image>
        </actor>
        <actor>
            <name>Ellen Page</name>
            <image>Ellen-Page.jpg</image>
        </actor>
        <actor>
            <name>Tom Hardy</name>
            <image>Tom-Hardy.jpg</image>
        </actor>
    </movie>
    <movie>
        <title>Blade II</title>
        <director>Guillermo del Toro</director>
        <artwork>Blade-II.jpg</artwork>
        <actor>
            <name>Wesley Snipes</name>
            <image>Wesley-Snipes.jpg</image>
        </actor>
        <actor>
            <name>Kris Kristofferson</name>
            <image>Kris-Kristofferson.jpg</image>
        </actor>
        <actor>
            <name>Ron Perlman</name>
            <image>Ron-Perlman.jpg</image>
        </actor>
        <actor>
            <name>Leonor Varela</name>
            <image>Leonor-Varela.jpg</image>
        </actor>
        <actor>
            <name>Norman Reedus</name>
            <image>Norman-Reedus.jpg</image>
        </actor>
    </movie>
    <movie>
        <title>Pulp Fiction</title>
        <director>Quentin Tarantino</director>
        <artwork>Pulp-Fiction.jpg</artwork>
        <actor>
            <name>John Travolta</name>
            <image>John-Travolta.jpg</image>
        </actor>
        <actor>
            <name>Samuel L Jackson</name>
            <image>Samuel-L-Jackson.jpg</image>
        </actor>
        <actor>
            <name>Uma Thurman</name>
            <image>Uma-Thurman.jpg</image>
        </actor>
        <actor>
            <name>Harvey Keitel</name>
            <image>Harvey-Keitel.jpg</image>
        </actor>
    </movie>
        <movie>
        <title>Avatar</title>
        <director>James Cameron</director>
        <artwork>Avatar.jpg</artwork>
        <actor>
            <name>Sam Worthington</name>
            <image>Sam-Worthington.jpg</image>
        </actor>
        <actor>
            <name>Zoe Saldana</name>
            <image>Zoe-Saldana.jpg</image>
        </actor>
        <actor>
            <name>Stephen Lang</name>
            <image>Stephen-Lang.jpg</image>
        </actor>
        <actor>
            <name>Michelle Rodriguez</name>
            <image>Michelle-Rodriguez.jpg</image>
        </actor>
    </movie>
</movies>

Thanks for taking the patience to bear with my question!

  • 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-27T02:45:30+00:00Added an answer on May 27, 2026 at 2:45 am

    jQuery for the win! http://api.jquery.com/jQuery.parseXML/

    This document can then be passed to jQuery to create a typical jQuery
    object that can be traversed and manipulated.

    If you are familiar with using jQuery, then there shouldn’t be any problem to traverse the parsed data as a typical jQuery object.

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

Sidebar

Related Questions

I'm working on a simple javascript login for a site, and have come up
I'm working on a simple game engine in Javascript (crazy, I know.) Screenshot from
Simple problem. I'm working on a single SQL Server database which is shared between
I have a movie database (postgreSQL). One of tables contains actors and movie titles.
I am coding a simple movie timeline in Flash CS5 actionscript 3.0. I have
I'm working on a simple 2D game (birds eye view). I have projectiles, which
I am working on a website that has access data from a database (sql
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
Working on a simple C program I'm stuck with an if test: int line_number
I'm working on a simple ASP.Net page (handler, actually) where I check the value

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.