Hi,
I have problem to binding Hierarchical XML Data using javascript recordset. Here the sample xml and html files are attached.
my question is how to get the "IpDigits" or "Port" values from xml by using the javascript recordset method.
please help me.
thanks,
XML file(Station_Table.xml)
<Stations>
<Station>
<StnNo>2030</StnNo>
<TSTCKT>16</TSTCKT>
<TLSNODE>4</TLSNODE>
<TLSPORT>3</TLSPORT>
<addr>
<TCPIP>
<IpDigits>127.0.0.1</IpDigits>
<Port>52030</Port>
</TCPIP>
</addr>
</Station>
</Stations>
HTML file to parse the xml file above
<xml id = "Stations" src="Station_Table.xml"></xml>
<p align="center"> <img border="0" src="Image.gif" alt="banner"/> </p>
<p></p>
<p align="center" style="font-size:20px; color:#336666; font-weight: 900">Station Display In Detail:</p>
<p align="center">Station Number : <input type="text" id ="searchtext" size="20" onkeypress="keyPressed()" />
<button onclick="findStn()">Display</button> </p>
<hr size="5" />
<div align="center" style="font-size:15px" id="searchresult">
<b><Please Enter a Station Number to View in the Text Box.></b> </div>
<script type="text/javascript" language="JavaScript">
var outputresult
function keyPressed ( k )
{
var hitEnter=event.keyCode
if ( hitEnter == 13 ){
findStn ( )
}
}
function findStn ( )
{
var searchstring = searchtext.value.toUpperCase()
if ( searchstring=="" )
{
searchresult.innerHTML = "<b><Please Enter a Station
Number to View in the Text Box.></b>"
return
}
Stations.recordset.MoveFirst()
outputresult = ""
while (!Stations.recordset.EOF)
{
var namestring = Stations.recordset("StnNo").Value
if (namestring.toUpperCase().indexOf(searchstring,0)==0)
{
if ( namestring.charAt(3) == searchstring.charAt(3) )
{
outputresult += "STN:" + " <b> "+namestring +" </b>
</br>"
outputresult += "CKT:" + " <b> "+Stations.recordset
("TSTCKT") +" </b> </br>"
outputresult += "NODE :" + "
<b> "+Stations.recordset("TLSNODE") +" </b> </br>"
outputresult += "PORT:" + " <b> "+Stations.recordset
("TLSPORT") +" </b> </br>"
////problem here to get values from /addr/TCPIP/
var 1 = Stations.recordset.nextRecordSet()
var 2 = 1.recordset.nextRecordSet()
var x = 2.recordset("IpDigits")
////problem here
outputresult += "IP:" + " <b> "+ x +" </b> </p>"
}
}
Stations.recordset.MoveNext()
}
if (outputresult=="")
searchresult.innerHTML = "<b><Sorry, Given Station
not defined.></b>"
else
searchresult.innerHTML = outputresult
}
</script>
</body>
I have problem to binding Hierarchical XML Data using javascript recordset. Here the sample xml and html files are attached.
my question is how to get the "IpDigits" or "Port" values from xml by using the javascript recordset method.
please help me.
thanks,
XML file(Station_Table.xml)
<Stations>
<Station>
<StnNo>2030</StnNo>
<TSTCKT>16</TSTCKT>
<TLSNODE>4</TLSNODE>
<TLSPORT>3</TLSPORT>
<addr>
<TCPIP>
<IpDigits>127.0.0.1</IpDigits>
<Port>52030</Port>
</TCPIP>
</addr>
</Station>
</Stations>
HTML file to parse the xml file above
<xml id = "Stations" src="Station_Table.xml"></xml>
<p align="center"> <img border="0" src="Image.gif" alt="banner"/> </p>
<p></p>
<p align="center" style="font-size:20px; color:#336666; font-weight: 900">Station Display In Detail:</p>
<p align="center">Station Number : <input type="text" id ="searchtext" size="20" onkeypress="keyPressed()" />
<button onclick="findStn()">Display</button> </p>
<hr size="5" />
<div align="center" style="font-size:15px" id="searchresult">
<b><Please Enter a Station Number to View in the Text Box.></b> </div>
<script type="text/javascript" language="JavaScript">
var outputresult
function keyPressed ( k )
{
var hitEnter=event.keyCode
if ( hitEnter == 13 ){
findStn ( )
}
}
function findStn ( )
{
var searchstring = searchtext.value.toUpperCase()
if ( searchstring=="" )
{
searchresult.innerHTML = "<b><Please Enter a Station
Number to View in the Text Box.></b>"
return
}
Stations.recordset.MoveFirst()
outputresult = ""
while (!Stations.recordset.EOF)
{
var namestring = Stations.recordset("StnNo").Value
if (namestring.toUpperCase().indexOf(searchstring,0)==0)
{
if ( namestring.charAt(3) == searchstring.charAt(3) )
{
outputresult += "STN:" + " <b> "+namestring +" </b>
</br>"
outputresult += "CKT:" + " <b> "+Stations.recordset
("TSTCKT") +" </b> </br>"
outputresult += "NODE :" + "
<b> "+Stations.recordset("TLSNODE") +" </b> </br>"
outputresult += "PORT:" + " <b> "+Stations.recordset
("TLSPORT") +" </b> </br>"
////problem here to get values from /addr/TCPIP/
var 1 = Stations.recordset.nextRecordSet()
var 2 = 1.recordset.nextRecordSet()
var x = 2.recordset("IpDigits")
////problem here
outputresult += "IP:" + " <b> "+ x +" </b> </p>"
}
}
Stations.recordset.MoveNext()
}
if (outputresult=="")
searchresult.innerHTML = "<b><Sorry, Given Station
not defined.></b>"
else
searchresult.innerHTML = outputresult
}
</script>
</body>