sXML2 = goBO.QueryXML("select avg(kpi) as avr, c_main from kpitable where kpi is not null group by c_main" ,"TYPES","TYPE")
if goBO.HasError then HandleError
Set oXML2 = Server.CreateObject("MSXML.DOMDocument")
oXML2.async = false
oXML2.loadXML sXML2
For each oNode2 in oXML2.documentElement.childNodes
BUt i need only "c_main" means the names which are in xml file.....
but in code if i use like this am getting the names(c_main)...
'Phase1Desc = oXML2.documentElement.childNodes(0).getAttribute("C_MAIN")
but i need to give near...
childnode(0)
childnode(1)
childnode(2)
childnode(3)
.....and so on
now i need to bind the names to dropdownlist......
some thing like this....
<td>Name</td>
<td>:<select id="c_main" name="c_main" >
<option value ="" selected="selected">Please Select</option>
<option value="<%= sDataPoint2%>"> </option><br/></td>
but here am not getting the names near "sDataPoint2"...
can some body help meee.....
<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("employee.xml");
}
function readXML()
{
if(xmlDoc.readyState == 4)
{
//Using documentElement Properties
//Output company
alert("XML Root Tag Name: " + xmlDoc.documentElement.tagName);
//Using firstChild Properties
//Output year
alert("First Child: " + xmlDoc.documentElement.childNodes[1].firstChild.tagName);
//Using lastChild Properties
//Output average
alert("Last Child: " + xmlDoc.documentElement.childNodes[1].lastChild.tagName);
//Using nodeValue and Attributes Properties
//Here both the statement will return you the same result
//Output 001
alert("Node Value: " + xmlDoc.documentElement.childNodes[0].attributes[0].nodeValue);
alert("Node Value: " + xmlDoc.documentElement.childNodes[0].attributes.getNamedItem("id").nodeValue);
//Using getElementByTagName Properties
//Here both the statement will return you the same result
//Output 2000
alert("getElementsByTagName: " + xmlDoc.getElementsByTagName("year")[0].attributes.getNamedItem("id").nodeValue);
//Using text Properties
//Output John
alert("Text Content for Employee Tag: " + xmlDoc.documentElement.childNodes[0].text);
//Using hasChildNodes Properties
//Output True
alert("Checking Child Nodes: " + xmlDoc.documentElement.childNodes[0].hasChildNodes);
}
}
</script>
</head>
<body onload="loadxml();">
</body>
</html>
Please mark the replies as answers if they help or unmark if not.
Feedback to us
anilr499
Member
94 Points
393 Posts
how to get the values from xml file to dropdownlist in javascript
May 16, 2012 07:05 AM|LINK
i have a asp code in which i get an xml file.....
here is my code....
sXML2 = goBO.QueryXML("select avg(kpi) as avr, c_main from kpitable where kpi is not null group by c_main" ,"TYPES","TYPE")
if goBO.HasError then HandleError
Set oXML2 = Server.CreateObject("MSXML.DOMDocument")
oXML2.async = false
oXML2.loadXML sXML2
For each oNode2 in oXML2.documentElement.childNodes
'Phase1Desc = oXML2.documentElement.childNodes(0).getAttribute("C_MAIN")
Phase1Desc = oNode2.getAttribute("C_MAIN")
Phase2Desc = oNode2.getAttribute("AVR")
sDataPoint2 = sDataPoint2 + "+'<vc:DataPoint """ & Phase1Desc &""" """ & Phase2Desc & """ />'" + vbNewline
Next
sDataPoint2 = sDataPoint2 + "+'</vc:DataSeries.DataPoints></vc:DataSeries>'"
Set oXML2 = nothing
my xml file is:
•+'<vc:DataPoint "Amran Bin Abdul Latip" "1" />' +'<vc:DataPoint "Anthony Chin Min Khong" "1" />
' +'<vc:DataPoint "Asmadi Bin Abd Malek" "3" />' +'<vc:DataPoint "Cheah Sook Yee" "2" />'
+'<vc:DataPoint "Chong Swee Leong" "1" />' +'<vc:DataPoint "Choo Hwee Ping" "1" />'
+'<vc:DataPoint "Denis Thomas" "3" />' +'<vc:DataPoint "Gan Kah Soon" "2" />'
+'<vc:DataPoint "Harlina Kamal Mokhtar" "3" />' +'<vc:DataPoint "Jeffrey Khoo Hock Soon" "3" />'
+'<vc:DataPoint "Kang Yew Jin" "2" />' +'<vc:DataPoint "Leong Cheng Keong" "3" />'
+'<vc:DataPoint "Lim Poh Pen" "2" />' +'<vc:DataPoint "Mohd Amin Mahboob Ali" "2" />'
+'<vc:DataPoint "Ng Kah Wah" "2" />' +'<vc:DataPoint "Ngapiah Binti Ahmad" "2" />'
+'<vc:DataPoint "Norharfiza Puasa" "5" />' +'<vc:DataPoint "R. Hariharan" "2" />'
+'<vc:DataPoint "Rina Sarif" "1" />' +'<vc:DataPoint "Ronnie Ray Fabian" "2" />'
+'<vc:DataPoint "Rozita Mohd Zain" "2" />' +'<vc:DataPoint "Tan Kok Soon" "2" />'
+'<vc:DataPoint "Tan Sai Sung" "2" />' +'<vc:DataPoint "Tee Soong Heong" "1" />'
+'<vc:DataPoint "Tengku Nor Nasrin Tengku Mohamed" "3" />'
+'<vc:DataPoint "Thomas Leong Yew Hong" "1" />' +'<vc:DataPoint "Yap Shaw Shong" "2" />'
+'<vc:DataPoint "Yee Su Pao" "2" />' +'<vc:DataPoint "Yusnida Binti Mohamed Yunus" "3" />'
+'</vc:DataSeries.DataPoints></vc:DataSeries>
BUt i need only "c_main" means the names which are in xml file.....
but in code if i use like this am getting the names(c_main)...
'Phase1Desc = oXML2.documentElement.childNodes(0).getAttribute("C_MAIN")
but i need to give near...
childnode(0)
childnode(1)
childnode(2)
childnode(3)
.....and so on
now i need to bind the names to dropdownlist......
some thing like this....
<td>Name</td>
<td>:<select id="c_main" name="c_main" >
<option value ="" selected="selected">Please Select</option>
<option value="<%= sDataPoint2%>"> </option><br/></td>
but here am not getting the names near "sDataPoint2"...
can some body help meee.....
Ravi Kumar K...
Member
735 Points
159 Posts
Re: how to get the values from xml file to dropdownlist in javascript
May 16, 2012 07:07 AM|LINK
http://stackoverflow.com/questions/9882404/how-to-make-dynamic-dropdownlist-populated-by-xml-data
http://stackoverflow.com/questions/5851487/how-to-create-a-dropdownlist-from-an-xml-file
Song-Tian - ...
All-Star
43715 Points
4304 Posts
Microsoft
Re: how to get the values from xml file to dropdownlist in javascript
May 23, 2012 06:15 AM|LINK
Hi,
Please refer to the code as follow:
<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("employee.xml"); } function readXML() { if(xmlDoc.readyState == 4) { //Using documentElement Properties //Output company alert("XML Root Tag Name: " + xmlDoc.documentElement.tagName); //Using firstChild Properties //Output year alert("First Child: " + xmlDoc.documentElement.childNodes[1].firstChild.tagName); //Using lastChild Properties //Output average alert("Last Child: " + xmlDoc.documentElement.childNodes[1].lastChild.tagName); //Using nodeValue and Attributes Properties //Here both the statement will return you the same result //Output 001 alert("Node Value: " + xmlDoc.documentElement.childNodes[0].attributes[0].nodeValue); alert("Node Value: " + xmlDoc.documentElement.childNodes[0].attributes.getNamedItem("id").nodeValue); //Using getElementByTagName Properties //Here both the statement will return you the same result //Output 2000 alert("getElementsByTagName: " + xmlDoc.getElementsByTagName("year")[0].attributes.getNamedItem("id").nodeValue); //Using text Properties //Output John alert("Text Content for Employee Tag: " + xmlDoc.documentElement.childNodes[0].text); //Using hasChildNodes Properties //Output True alert("Checking Child Nodes: " + xmlDoc.documentElement.childNodes[0].hasChildNodes); } } </script> </head> <body onload="loadxml();"> </body> </html>Feedback to us
Develop and promote your apps in Windows Store
asteranup
All-Star
30184 Points
4906 Posts
Re: how to get the values from xml file to dropdownlist in javascript
May 23, 2012 06:19 AM|LINK
Hi,
You can do this using ajax-
Using jQuery-
http://think2loud.com/224-reading-xml-with-jquery/
Using xmlHttpRequest object-
http://www.w3schools.com/ajax/ajax_xmlfile.asp
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog