I have been trying to display all child nodes of the parent node based on the attribute type using JS
Requirement:
user gives three I/P as :
1)"Ram" "Student" "a1"
O/P :should display all the child elements based on name & type selected
aaa,aaaaaaaa,aaaa
2)"Ram" "Student" "a2" :
xxxx,tttttt,yyyy
XML:
<?xml version="1.0" ?>
<root>
    <program name="Ram">
        <computation type="student">
            <module type="a1">              
                <modPath>aaa</modPath>
                <modInputTemplate>aaaaaaaa</modInputTemplate>
                <modSchematic>aaaa</modSchematic>
            </module>
            <module type="a2">              
                <modPath>xxxx</modPath>
                <modInputTemplate>tttttt</modInputTemplate>
                <modSchematic>yyyy</modSchematic>
            </module>
        </computation>
        <computation type="Employee">
            <module type="b1">              
                <modPath>lllll</modPath>
                <modInputTemplate>llllll</modInputTemplate>
                <modSchematic>lllll</modSchematic>
            </module>
            <module type="b2">              
                <modPath>mmmmmmmmm</modPath>
                <modInputTemplate>mmmmmmmm</modInputTemplate>
                <modSchematic>mmmmmm</modSchematic>
            </module>
        </computation>      
    </program>
    <program name="Rahul">
    .......
    .......
    .......
    </program>
    <program name="Ramesh">
    .......
    .......
    .......
    </program>
</root>
I have JS to display the Child nodes ,But its not based on the attribute value
    <html>
<head>
<title>Read XML in Microsoft Browsers</title>
<script type="text/javascript">
    var xmlDoc;
    function loadxml()
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.onreadystatechange = readXML;
        xmlDoc.load("writers.xml");
    }
    function readXML()
    {
        if(xmlDoc.readyState == 4){
            myFunction(xmlDoc);
        }
        function myFunction(xml) {
            var x, i, txt;
            txt = "";
            var x = xmlDoc.getElementsByTagName("module");//Here "module" should be replaced by attribute value which user gives as i/p
            for( i = 0; i < x[0].childNodes.length; i++) {
                txt += x[0].childNodes[i].nodeName + ": " + x[0].childNodes[i].childNodes[0].nodeValue + "<br>";
            }
            document.getElementById("demo").innerHTML = txt;
        }
    }
</script>
</head>
<body onload="loadxml()">
    <p id="demo">Write output of loadxml()</p>
    <p id="test">Test me!</p>
</body>
</html>

