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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:41:46+00:00 2026-05-29T15:41:46+00:00

What I’m trying to do is to parse multiple entries from xml to html!

  • 0

What I’m trying to do is to parse multiple entries from xml to html! This is script which i wrote to do that:

<body>  
<script type="text/javascript">
    if (window.XMLHttpRequest){
        xmlhttp=new XMLHttpRequest();
    }
    else{
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET", "distros.xml", false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;

    var counter=0;
    for(i=0; i<30; i++){
        var level=xmlDoc.getElementsByTagName("for")[i].childNodes[0].nodeValue;
        if(level=="Beginners"){
            counter++;
        }
    }

    for(i=0; i<counter; i++){
        document.write('<div id="page">');
            document.write('<div id="page-top">');
                document.write('<div id="page-bottom">');
                    document.write('<div id="content">');
                        document.write('<div class="post">');
                            document.write('<h2 class="title"><span id="'name'+i"></span></h2>');
// This is the line                                                      ^^^^^^^^
//  with the error                                                       ||||||||
//-------------------------------------------------------------------------------
                            document.write('<div class="entry">');
                                document.write('<p><b>Based on: </b> <span id="'based_on'+i"></span><br />');
                                document.write('<b>Architecture: </b> <span id="'architecture'+i"></span><br />');
                                document.write('<b>Desktop: </b> <span id="'desktop'+i"></span><br />');
                                document.write('<b>Origin: </b> <span id="'origin'+i"></span><br />');
                                document.write('<b>Description: </b> <span id="'description'+i"></span></p>');
                            document.write('</div>');
                        document.write('</div>');
                    document.write('</div>');
                document.write('</div>');
            document.write('</div>');
        document.write('</div>');
    }
</script>

<script type="text/javascript">
    if (window.XMLHttpRequest){
        xmlhttp=new XMLHttpRequest();
    }
    else{
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET", "distros.xml", false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;

    for(i=0; i<30; i++){

        var level=xmlDoc.getElementsByTagName("for")[i].childNodes[0].nodeValue;

        if(level=="Beginners"){
            document.getElementById("'name'+i").innerHTML=
            xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue;
            document.getElementById("'based_on'+i").innerHTML=
            xmlDoc.getElementsByTagName("based_on")[i].childNodes[0].nodeValue;
            document.getElementById("'architecture'+i").innerHTML=
            xmlDoc.getElementsByTagName("architecture")[i].childNodes[0].nodeValue;
            document.getElementById("'desktop'+i").innerHTML=
            xmlDoc.getElementsByTagName("desktop")[i].childNodes[0].nodeValue;
            document.getElementById("'origin'+i").innerHTML=
            xmlDoc.getElementsByTagName("origin")[i].childNodes[0].nodeValue;
            document.getElementById("'description'+i").innerHTML=
            xmlDoc.getElementsByTagName("description")[i].childNodes[0].nodeValue;
        }
    }
</script>

well… guess what, it’s not working!
This is the small part of xml file I’m trying to parse:

<linux>

<distributions>

    <distribution>
        <name>Mint</name>
        <for>Beginners</for>
        <based_on>Debian, Ubuntu</based_on>
        <architecture>i386, x86_64</architecture>
        <desktop>Fluxbox, GNOME, KDE, LXDE, Xfce</desktop>
        <origin>Ireland</origin>
        <description>Linux Mint is an Ubuntu-based distribution whose goal is to provide a more complete out-of-the-box experience by including browser plugins, media codecs, support for DVD playback, Java and other components. It also adds a custom desktop and menus, several unique configuration tools, and a web-based package installation interface. Linux Mint is compatible with Ubuntu software repositories.</description>
    </distribution>

    <distribution>
        <name>Ubuntu</name>
        <for>Beginners</for>
        <based_on>Debian</based_on>
        <architecture>i686, x86_64</architecture>
        <desktop>KDE, LXDE, Unity, Xfce</desktop>
        <origin>Isle of Man</origin>
        <description>Ubuntu is a complete desktop Linux operating system, freely available with both community and professional support. The Ubuntu community is built on the ideas enshrined in the Ubuntu Manifesto: that software should be available free of charge, that software tools should be usable by people in their local language and despite any disabilities, and that people should have the freedom to customise and alter their software in whatever way they see fit. "Ubuntu" is an ancient African word, meaning "humanity to others". The Ubuntu distribution brings the spirit of Ubuntu to the software world.</description>
    </distribution>

    <distribution>
        <name>Fedora</name>
        <for>Experienced</for>
        <based_on>Independent</based_on>
        <architecture>i686, x86_64</architecture>
        <desktop>GNOME, KDE, LXDE, Openbox, Xfce</desktop>
        <origin>USA</origin>
        <description>The Fedora Project is an openly-developed project designed by Red Hat, open for general participation, led by a meritocracy, following a set of project objectives. The goal of The Fedora Project is to work with the Linux community to build a complete, general purpose operating system exclusively from open source software. Development will be done in a public forum. The project will produce time-based releases of Fedora about 2-3 times a year, with a public release schedule. The Red Hat engineering team will continue to participate in building Fedora and will invite and encourage more outside participation than in past releases. By using this more open process, we hope to provide an operating system more in line with the ideals of free software and more appealing to the open source community.</description>
    </distribution>

    <distribution>
        <name>Debian</name>
        <for>Advanced</for>
        <based_on>Independent</based_on>
        <architecture>amd64, armel, hppa, ia64, i386, mips, mipsel, powerpc, s390, sparc64, x86_64</architecture>
        <desktop>AfterStep, Blackbox, Fluxbox, GNOME, IceWM, KDE, LXDE, Openbox, WMaker, Xfce</desktop>
        <origin>Global</origin>
        <description>The Debian Project is an association of individuals who have made common cause to create a free operating system. This operating system is called Debian GNU/Linux, or simply Debian for short. Debian systems currently use the Linux kernel. Linux is a completely free piece of software started by Linus Torvalds and supported by thousands of programmers worldwide. Of course, the thing that people want is application software: programs to help them get what they want to do done, from editing documents to running a business to playing games to writing more software. Debian comes with over 20,000 packages (precompiled software that is bundled up in a nice format for easy installation on your machine) - all of it free. It's a bit like a tower. At the base is the kernel. On top of that are all the basic tools. Next is all the software that you run on the computer. At the top of the tower is Debian -- carefully organizing and fitting everything so it all works together.</description>
    </distribution>
</distributions>

  • 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-29T15:41:50+00:00Added an answer on May 29, 2026 at 3:41 pm

    Take a look at this:

    var brojac=0:
    var lvl=xmlDoc.getElementsByTagName("for")[i].childNodes[0].nodeValue;
    //---------------------------------------- ^
    for(i=0; i<30; i++){
        if(lvl=="Beginners"){
            brojac++;
        }
    }
    
    for(j=0; j<brojac; j++){
    

    The marked i is unknown at this place, so the whole line will fail.(usually the whole script should stop from executing there, you should receive an exception)

    The loop that should increment brojac will do nothing(lvl will never be “Beginners”) and the last of the lines will never run, because brojac will always be 0

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string

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.