How to parse xml file dynamically in XUL locally using XMLHttpRequest
I my XUL window i have a menu-list to display my <PDE-Identity>N65539</PDE-Identity> values and text-boxes to display the corresponding XML elements.

In my menu-list, how can i list all the PDE-Identity dynamically as a menu-items in menu-list.
Then, if a user selects any one of the  PDE-Identity then it should display all the corresponding value of the PDE-Identity number in the respective text-boxes.

I have parsed the XML file but I couldn't load the information dynamically as i have mentioned above.

I know that i have to make a loop to load the information but i couldn't do it. Please help me with this.. Thank guys..


    <?xml version="1.0"?>
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
            
      <grid>
        <columns>
          <column flex="1"/>
          <column flex="4"/>
           <column flex="4"/>
          <column flex="4"/>
           <column flex="4"/>
        </columns>
     
        <rows>
          <row>
    <label control="" value="Select PDE-ID:"/>
    <menulist id="List">
                   <menupopup  id="Popup">
                    <menuitem/>
                   </menupopup>
    </menulist>
     
          </row>
        </rows>
    </grid>
     
    <label control="" accesskey="" value=""/>
      <grid>
        <columns>
          <column flex="1"/>
          <column flex="4"/>
            <column flex="4"/>
            <column flex="4"/>
    <column flex="4"/>
        </columns>
     
        <rows>
          <row>
            <label value="PDE-Identity"/>
            <textbox id="pde" value=""/>
          </row>
          <row>
            <label value="FirstName"/>
            <textbox id="fname" value=""/>
          </row>
          <row>
            <label value="LastName"/>
            <textbox id="lname" value=""/>
          </row>
          <row>
              <label value="Gmail"/>
            <textbox id="gmail" value=""/>
          </row>
          <row>
              <label value="Yahoo"/>
            <textbox id="yahoo" value=""/>
          </row>
          <row>
              <label value="Alcatel-Lucent"/>
            <textbox id="alcatel-lucent" value="" />
          </row>
          <row>
              <label value="URL"/>
            <textbox id="facebook" value="" />
          </row>
          <row>
              <label value="Facebook-ID"/>
            <textbox id="fid" value="" />
          </row>
        </rows>
      </grid>
    <label  value=""/>
    <grid>
        <columns>
            <column flex=""/>
        <hbox align="center" >
            <button id="save"   label="Save"   oncommand="save();" />
            <button id="cancel" label="Cancel" oncommand="cancel();"/>
            <button id="delete" label="Merge"  oncommand="delete();"/>      
        </hbox>
    </columns>
    </grid>
     
     
    <separator/>
    <text value="© 2011"/>
    <separator/>
    
    
    <script type="application/x-javascript">
    <![CDATA[
    
    function onload(){
    
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    
    var objXMLDoc = document.implementation.createDocument('','doc',null);
    var objXMLHTTP = new XMLHttpRequest();
    
    objXMLHTTP.open("GET", "file://D:/xmlparserinxul/final.xml", false);
    //alert('hi');
    objXMLHTTP.send(null);
    objXMLDoc = objXMLHTTP.responseXML;
    
    var str=objXMLDoc.getElementsByTagName("PDE-Identity")[0].childNodes[0].nodeValue;
    document.getElementById("pde").value=str;
    
    var str=objXMLDoc.getElementsByTagName("FirstName")[0].childNodes[0].nodeValue;
    document.getElementById("fname").value=str;
    
    var str=objXMLDoc.getElementsByTagName("LastName")[0].childNodes[0].nodeValue;
    document.getElementById("lname").value=str;
    
    var str=objXMLDoc.getElementsByTagName("URL")[0].nodeValue;
    document.getElementById("facebook").value=str;
    
    var str=objXMLDoc.getElementsByTagName("Facebook-ID")[0].nodeValue;
    document.getElementById("fid").value=str;
    
    
    }
    
    ]]>
    </script>
    
    </window>

My XML file:


    <?xml version="1.0" encoding="UTF-8"?>
    <CONTACTS>
    <CONTACT>
    <PDE-Identity>N65539</PDE-Identity>
    <FirstName>Arun_niit</FirstName>
    <LastName>Arun_niit</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>nura_ice@yahoo.co.in</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65546</PDE-Identity>
    <FirstName>FodenBen'</FirstName>
    <LastName>Ben' Foden</LastName>
    <URL>http://www.facebook.com/profile.php?id=100002440474277</URL>
    <Facebook-ID>100002440474277</Facebook-ID>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65553</PDE-Identity>
    <FirstName>GhorbelMahmoud</FirstName>
    <LastName>Mahmoud Ghorbel</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>alcatel-lucent</Type>
    <Value>mahmoud.ghorbel@alcatel-lucent.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65560</PDE-Identity>
    <FirstName>keyankarthik</FirstName>
    <LastName>karthik keyan</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>karthycse@yahoo.co.in</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65567</PDE-Identity>
    <FirstName>Rangarajkarthik</FirstName>
    <LastName>karthik Rangaraj</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>gmail</Type>
    <Value>kart2006@gmail.com</Value>
    </EMail>
    <EMail>
    <Type>yahoo</Type>
    <Value>karthikrangaraj@yahoo.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65576</PDE-Identity>
    <FirstName>ReddyAkky</FirstName>
    <LastName>Akky Reddy</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>gmail</Type>
    <Value>akkireddych@gmail.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65583</PDE-Identity>
    <FirstName>SandfordFrankie</FirstName>
    <LastName>Frankie Sandford</LastName>
    <URL>http://www.facebook.com/FrankieSandfordApprovedPage</URL>
    <Facebook-ID/>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65590</PDE-Identity>
    <FirstName>TheSatsRochelle</FirstName>
    <LastName>Rochelle TheSats</LastName>
    <URL>http://www.facebook.com/profile.php?id=100002487211054</URL>
    <Facebook-ID>100002487211054</Facebook-ID>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65597</PDE-Identity>
    <FirstName>KumarVeera</FirstName>
    <LastName>Veera_Kumar</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>KUMARg_81@yahoo.com</Value>
    </EMail>
    <EMail>
    <Type>gmail</Type>
    <Value>KUMARg_81@gmail.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    </CONTACTS>


How to parse xml file dynamically in XUL locally using XMLHttpRequest
===

I my XUL window i have a menu-list to display my <PDE-Identity>N65539</PDE-Identity> values and text-boxes to display the corresponding XML elements.

In my menu-list, how can i list all the PDE-Identity dynamically as a menu-items in menu-list.
Then, if a user selects any one of the  PDE-Identity then it should display all the corresponding value of the PDE-Identity number in the respective text-boxes.

I have parsed the XML file but I couldn't load the information dynamically as i have mentioned above.

I know that i have to make a loop to load the information but i couldn't do it. Please help me with this.. Thank guys..


    <?xml version="1.0"?>
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
            
      <grid>
        <columns>
          <column flex="1"/>
          <column flex="4"/>
           <column flex="4"/>
          <column flex="4"/>
           <column flex="4"/>
        </columns>
     
        <rows>
          <row>
    <label control="" value="Select PDE-ID:"/>
    <menulist id="List">
                   <menupopup  id="Popup">
                    <menuitem/>
                   </menupopup>
    </menulist>
     
          </row>
        </rows>
    </grid>
     
    <label control="" accesskey="" value=""/>
      <grid>
        <columns>
          <column flex="1"/>
          <column flex="4"/>
            <column flex="4"/>
            <column flex="4"/>
    <column flex="4"/>
        </columns>
     
        <rows>
          <row>
            <label value="PDE-Identity"/>
            <textbox id="pde" value=""/>
          </row>
          <row>
            <label value="FirstName"/>
            <textbox id="fname" value=""/>
          </row>
          <row>
            <label value="LastName"/>
            <textbox id="lname" value=""/>
          </row>
          <row>
              <label value="Gmail"/>
            <textbox id="gmail" value=""/>
          </row>
          <row>
              <label value="Yahoo"/>
            <textbox id="yahoo" value=""/>
          </row>
          <row>
              <label value="Alcatel-Lucent"/>
            <textbox id="alcatel-lucent" value="" />
          </row>
          <row>
              <label value="URL"/>
            <textbox id="facebook" value="" />
          </row>
          <row>
              <label value="Facebook-ID"/>
            <textbox id="fid" value="" />
          </row>
        </rows>
      </grid>
    <label  value=""/>
    <grid>
        <columns>
            <column flex=""/>
        <hbox align="center" >
            <button id="save"   label="Save"   oncommand="save();" />
            <button id="cancel" label="Cancel" oncommand="cancel();"/>
            <button id="delete" label="Merge"  oncommand="delete();"/>      
        </hbox>
    </columns>
    </grid>
     
     
    <separator/>
    <text value="© 2011"/>
    <separator/>
    
    
    <script type="application/x-javascript">
    <![CDATA[
    
    function onload(){
    
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    
    var objXMLDoc = document.implementation.createDocument('','doc',null);
    var objXMLHTTP = new XMLHttpRequest();
    
    objXMLHTTP.open("GET", "file://D:/xmlparserinxul/final.xml", false);
    //alert('hi');
    objXMLHTTP.send(null);
    objXMLDoc = objXMLHTTP.responseXML;
    
    var str=objXMLDoc.getElementsByTagName("PDE-Identity")[0].childNodes[0].nodeValue;
    document.getElementById("pde").value=str;
    
    var str=objXMLDoc.getElementsByTagName("FirstName")[0].childNodes[0].nodeValue;
    document.getElementById("fname").value=str;
    
    var str=objXMLDoc.getElementsByTagName("LastName")[0].childNodes[0].nodeValue;
    document.getElementById("lname").value=str;
    
    var str=objXMLDoc.getElementsByTagName("URL")[0].nodeValue;
    document.getElementById("facebook").value=str;
    
    var str=objXMLDoc.getElementsByTagName("Facebook-ID")[0].nodeValue;
    document.getElementById("fid").value=str;
    
    
    }
    
    ]]>
    </script>
    
    </window>

My XML file:


    <?xml version="1.0" encoding="UTF-8"?>
    <CONTACTS>
    <CONTACT>
    <PDE-Identity>N65539</PDE-Identity>
    <FirstName>Arun_niit</FirstName>
    <LastName>Arun_niit</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>nura_ice@yahoo.co.in</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65546</PDE-Identity>
    <FirstName>FodenBen'</FirstName>
    <LastName>Ben' Foden</LastName>
    <URL>http://www.facebook.com/profile.php?id=100002440474277</URL>
    <Facebook-ID>100002440474277</Facebook-ID>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65553</PDE-Identity>
    <FirstName>GhorbelMahmoud</FirstName>
    <LastName>Mahmoud Ghorbel</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>alcatel-lucent</Type>
    <Value>mahmoud.ghorbel@alcatel-lucent.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65560</PDE-Identity>
    <FirstName>keyankarthik</FirstName>
    <LastName>karthik keyan</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>karthycse@yahoo.co.in</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65567</PDE-Identity>
    <FirstName>Rangarajkarthik</FirstName>
    <LastName>karthik Rangaraj</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>gmail</Type>
    <Value>kart2006@gmail.com</Value>
    </EMail>
    <EMail>
    <Type>yahoo</Type>
    <Value>karthikrangaraj@yahoo.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65576</PDE-Identity>
    <FirstName>ReddyAkky</FirstName>
    <LastName>Akky Reddy</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>gmail</Type>
    <Value>akkireddych@gmail.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65583</PDE-Identity>
    <FirstName>SandfordFrankie</FirstName>
    <LastName>Frankie Sandford</LastName>
    <URL>http://www.facebook.com/FrankieSandfordApprovedPage</URL>
    <Facebook-ID/>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65590</PDE-Identity>
    <FirstName>TheSatsRochelle</FirstName>
    <LastName>Rochelle TheSats</LastName>
    <URL>http://www.facebook.com/profile.php?id=100002487211054</URL>
    <Facebook-ID>100002487211054</Facebook-ID>
    <EMAILS/>
    </CONTACT>
    <CONTACT>
    <PDE-Identity>N65597</PDE-Identity>
    <FirstName>KumarVeera</FirstName>
    <LastName>Veera_Kumar</LastName>
    <Facebook-ID/>
    <EMAILS>
    <EMail>
    <Type>yahoo</Type>
    <Value>KUMARg_81@yahoo.com</Value>
    </EMail>
    <EMail>
    <Type>gmail</Type>
    <Value>KUMARg_81@gmail.com</Value>
    </EMail>
    </EMAILS>
    </CONTACT>
    </CONTACTS>

