Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Hierarchical XML Data using javascript..

Status
Not open for further replies.

savichin

Programmer
Jan 30, 2007
3
US
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()" />&nbsp;
<button onclick="findStn()">Display</button> </p>
<hr size="5" />


<div align="center" style="font-size:15px" id="searchresult">
<b>&ltPlease Enter a Station Number to View in the Text Box.&gt</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>&ltPlease Enter a Station
Number to View in the Text Box.&gt</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>&ltSorry, Given Station
not defined.&gt</b>"
else
searchresult.innerHTML = outputresult
}
</script>
</body>
 
I've been looking for an answer for this question, it's a toughy, no info about this anywhere.

<.
 
The first thing you have to do is change the variable names 1 and 2 to something else. Those are illegal variable names. Then I get an error
Current provider does not support returning multiple recordsets from a single execution
I'm not sure if this is what you are running into, if it is, I have read that the error is a server issue.

<.
 
thanks you.
Is there any other approach to read Hierarchical XML data and display them. Please let me know. thanks for ur help;
savichin
 
Hi monksnake, I got the solution so how. You are right that provider does not support returning multiple recordsets from a single execution. So I used XSLT to get those params. thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top