xml SelectSingleNode

I'm using the following to display numbers from an xml in an asp page

For Each xmlNode In objXML.documentElement.selectNodes("Data[FundCode/text()='" & neaFundID & "']")

NEADayPnL = xmlNode.selectSingleNode("DayPnL").text

Next

***then im creating a recordset to load up the data ***

Set objRsBC  = CreateObject("ADODB.recordset")

            objRsBC.Fields.Append "NNWDayPnL", adVarChar, 100


objRsBC.open, , 2, 3
      objRsBC.AddNew
                  objRsBC.Fields("NNWDayPnL") = NNWDayPnL

then I'm calling  a function to display the number...

<%call vbproc(objRsBC("NNWSLDayPnL"), objRsBC("NNWSLDayPnL").name)%>



seems long winded, how would I select a single node and display the number with out creating a record set etc...

Thanks
nthawkins1971Asked:
Who is Participating?
 
ste5anConnect With a Mentor Senior DeveloperCommented:
Ah, you cannot do that much. I would just rewrite it to avoid the unnecessary Split() calls and clean it up. Something like this:

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<!--#include virtual="/adovbs.inc"-->
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>dataGrid</title>
        <link rel="stylesheet" type="text/css" href="CSS/NWP-MV.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    </head>
    <body>
        <!--#include file ="BookLevel.asp"-->
        <table border="0" cellpadding="0" cellspacing="0" width="2250">
        <tbody>
<%
    Sub AddFieldValue(AFieldName, ANode, ARecordset)
      ARecordset.Fields(AFieldName) = ANode.selectSingleNode(AFieldName).Text
    End Sub

    Function CreateRecordset()
      Set recordset  = CreateObject("ADODB.recordset")
      recordset.Fields.Append "EnsembleID", adDouble, 100
      recordset.Fields.Append "Issue", adVarChar, 100
      recordset.Fields.Append "LongPos", adVarChar, 100
      recordset.Fields.Append "StubPos", adVarChar, 100
      recordset.Fields.Append "SIV", adDouble, 100
      recordset.Fields.Append "Parity", adDouble, 100
      recordset.Fields.Append "Premium", adDouble, 100
      recordset.Fields.Append "IV", adDouble, 100
      recordset.Fields.Append "LongPx", adDouble, 100
      recordset.Fields.Append "PxChg", adDouble, 100
      recordset.Fields.Append "TheoChg", adDouble, 100
      recordset.Fields.Append "StubPrice", adDouble, 100
      recordset.Fields.Append "ShPxChgPer", adDouble, 100
      recordset.Fields.Append "SLH", adDouble, 100
      recordset.Fields.Append "CurDelta", adDouble, 100
      recordset.Fields.Append "ImpDelta", adDouble, 100
      recordset.Fields.Append "TheoDelta", adDouble, 100
      recordset.Fields.Append "FutHdg1", adDouble, 100
      recordset.Fields.Append "ImpVolCB", adDouble, 100
      recordset.Fields.Append "ImpVolStub", adDouble, 100
      recordset.Fields.Append "V90D", adDouble, 100
      recordset.Fields.Append "DPnL", adDouble, 100
      recordset.Fields.Append "WPnL", adDouble, 100
      recordset.Fields.Append "MPnL", adDouble, 100
      recordset.Fields.Append "YPnL", adDouble, 100
      recordset.Fields.Append "NetPnL", adDouble, 100
      recordset.Fields.Append "DayTE", adDouble, 100
      recordset.open, , 2, 3
      Set CreateRecordset = recordset
    End Function

    Function LoadRecordsetFromXml(ABookID)
      Set recordset = CreateRecordset()
      Set document = Server.CreateObject("MSXML2.DOMDocument.3.0")
      document.async = False
      document.Load (Server.MapPath("book/" & ABookID & ".xml"))
      Set nodelist = document.documentElement.selectNodes("/DocumentElement/Data")
      For Each node In nodelist
        recordset.AddNew
        AddFieldValue "EnsembleID", node, recordset
        AddFieldValue "Issue", node, recordset
        AddFieldValue "LongPos", node, recordset
        AddFieldValue "StubPos", node, recordset
        AddFieldValue "SIV", node, recordset
        AddFieldValue "Parity", node, recordset
        AddFieldValue "Premium", node, recordset
        AddFieldValue "IV", node, recordset
        AddFieldValue "LongPx", node, recordset
        AddFieldValue "PxChg", node, recordset
        AddFieldValue "TheoChg", node, recordset
        AddFieldValue "StubPrice", node, recordset
        AddFieldValue "ShPxChgPer", node, recordset
        AddFieldValue "SLH", node, recordset
        AddFieldValue "CurDelta", node, recordset
        AddFieldValue "ImpDelta", node, recordset
        AddFieldValue "TheoDelta", node, recordset
        AddFieldValue "FutHdg1", node, recordset
        AddFieldValue "ImpVolCB", node, recordset
        AddFieldValue "ImpVolStub", node, recordset
        AddFieldValue "V90D", node, recordset
        AddFieldValue "DPnL", node, recordset
        AddFieldValue "WPnL", node, recordset
        AddFieldValue "MPnL", node, recordset
        AddFieldValue "YPnL", node, recordset
        AddFieldValue "NetPnL", node, recordset
        AddFieldValue "DayTE", node, recordset
        recordset.Update
      Next

      Set node = Nothing
      Set nodelist = Nothing
      Set document = Nothing
      Set LoadRecordsetFromXml = recordset
    End Function

    Sub SortRecordset(ASortBy, ASortOrder, ARecordset)
      If Trim(ASortOrder) = "DESC" Then
        SortOrder = "ASC"
      Else
        SortOrder = "DESC"
      End If

      ARecordset.Sort =  ASortBy & " " & ASortOrder
    End Sub

    Sub OutputValue(AFieldName, ARecordset)
      vbproc ARecordset(AFieldName), ARecordset(AFieldName).Name
    End Sub

    BookID = request.querystring("BookID")
    SortBy = request.QueryString("sort")
    SortOrder = request.QueryString("xSortID")
    Set objRs = LoadRecordsetFromXml(BookID)
    SortRecordset SortBy, SortOrder, objRs
    objRs.movefirst
    Do While Not objRs.eof
%>
        <tr>
          <td><div align="center" class="bcklghtblue"><%Response.write left(objRs("EnsembleID"),15)%>   </div></td>
          <td><div align="left" style="padding-left:5px"  class="stubstyleborder"><%Response.write left(objRs("Issue"),15)%>    </div></td>
          <td bgcolor="f2f2f2"><div align="center">         <%call OutputValue("LongPos", objRs)%>      </div></td>
          <td><div align="center">                          <%call OutputValue("StubPos", objRs)%>      </div></td>
          <td><div align="center" class="stubstyleborder">  <%call OutputValue("SIV", objRs)%>          </div></td>
          <td><div align="center" class="blackstyle">       <%call OutputValue("Parity", objRs)%>       </div></td>
          <td><div align="center" class="blackstyle">       <%call OutputValue("Premium", objRs)%>%     </div></td>
          <td><div align="center">                          <%call OutputValue("IV", objRs)%>           </div></td>
          <td  bgcolor="f2f2f2"><div align="center">        <%call OutputValue("LongPx", objRs)%>       </div></td>
          <td><div align="center">                          <%call OutputValue("PxChg", objRs)%>        </div></td>
          <td><div align="center">                          <%call OutputValue("TheoChg", objRs)%>      </div></td>
          <td><div align="center">                          <%call OutputValue("StubPrice", objRs)%>    </div></td>
          <td><div align="center" class="stubstyleborder">  <%call OutputValue("ShPxChgPer", objRs)%>   </div></td>
          <td class="<%if formatnumber(objRs("SLH")*100,2) > 5 then
                            response.write "SLH"
                         end if%>"><div align="center">     <%call OutputValue("SLH", objRs)%>          </div></td>
          <td><div align="center" class="stubstyleborder">  <%call OutputValue("CurDelta", objRs)%>     </div></td>
          <td><div align="center">                          <%call OutputValue("ImpDelta", objRs)%>     </div></td>
          <td><div align="center">                          <%call OutputValue("TheoDelta", objRs)%>    </div></td>
          <td><div align="center">                          <%call OutputValue("FutHdg1", objRs)%>      </div></td>
          <td><div align="center">                          <%call OutputValue("ImpVolCB", objRs)%>     </div></td>
          <td><div align="center">                          <%call OutputValue("ImpVolStub", objRs)%>   </div></td>
          <td><div align="center">                          <%call OutputValue("V90D", objRs)%>         </div></td>
          <td><div align="center">                          <%call OutputValue("DPnL", objRs)%>         </div></td>
          <td><div align="center">                          <%call OutputValue("WPnL", objRs)%>         </div></td>
          <td><div align="center">                          <%call OutputValue("MPnL", objRs)%>         </div></td>
          <td><div align="center">                          <%call OutputValue("YPnL", objRs)%>         </div></td>
          <td><div align="center">                          <%call OutputValue("NetPnL", objRs)%>       </div></td>
          <td><div align="center">                          <%call OutputValue("DayTE", objRs)%>        </div></td>
        </tr>
<%
      objRs.MoveNext
    Loop
%>
        </tbody>
        </table>
    </body>
</html>

Open in new window

0
 
ste5anSenior DeveloperCommented:
Please post the entire code. Cause this snippet raise some logic questions..
0
 
nthawkins1971Author Commented:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
 <META HTTP-EQUIV="Expires" CONTENT="-1">
<!--#include virtual="/adovbs.inc"-->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>dataGrid</title>
<link rel="stylesheet" type="text/css" href="CSS/NWP-MV.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

</head>
<body>
<table width="2250" border="1" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td><div class="largerTXT"><a href="nav.html"><h1><%=request.QueryString("xBookID")%></h1></a>
        <div class="navbar">
          <div class="dropdown">
            <button class="dropbtn">Book Code</button>
            <div class="dropdown-content">
              <div class="row">
                <div class="column">
                  <h3>NNW</h3>
                
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-LV">NNW-LV</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV">NNW-MV**</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV2">NNW-MV2</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV4">NNW-MV4</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV5">NNW-MV5</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV6">NNW-MV6</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV6O">NNW-MV60</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MV7">NNW-MV7</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-CHINA">NNW-CHINA</a>
                   <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-MACRO">NNW-MACRO</a> 
                   <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NNW-LS">NNW-LS</a> </div>
                <div class="column">
                  <h3>NWAX</h3>
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-LV">NWAX-LV</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MV3">NWAX-MV3</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MV5">NWAX-MV5</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MV6">NWAX-MV6</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MV6O">NWAX-MV60</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MV7">NWAX-MV7</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-CHINA">NWAX-CHINA</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-MACRO">NWAX-MACRO</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-LS">NWAX-LS</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-SL">NWAX-SL</a> </div>
                <div class="column">
                  <h3>OTHER</h3>
                  <a href="dataGrid.asp?sort=Issue&xSortID= DESC&xBookID=NEA-EA1">NEA-EA1**</a>
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NEA-CSOP">NEA-CSOP</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NPA-MV">NPA-MV</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID= DESC&xBookID=NWP-MV">NWP-MV**</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWP-LV">NWP-LV</a> 
                  <a href="dataGrid.asp?sort=Issue&xSortID=%20DESC&xBookID=NWAX-EA3">NWAX-EA3</a> </div>
              </div>
            </div>
          </div>
        </div>
      </div></td>
    </tr>
  </tbody>
</table>

<!--#include file ="BookLevel.asp"-->

  <%
   xBookID = request.querystring("xBookID")
  
  
   Set objXML = Server.CreateObject("MSXML2.DOMDocument.3.0")
   objXML.async = False
	objXML.Load (Server.MapPath("book/" & xBookID & ".xml"))
	
	
'select each node in the data
	For Each xmlNode In objXML.documentElement.selectNodes("Data")

		

xEnsembleID = xEnsembleID & xmlNode.selectSingleNode("EnsembleID").text & ","
xIssue = xIssue & xmlNode.selectSingleNode("Issue").text & ","
xLongPos = xLongPos & xmlNode.selectSingleNode("LongPos").text & ","
xStubPos = xStubPos & xmlNode.selectSingleNode("StubPos").text & ","
xSIV = xSIV & xmlNode.selectSingleNode("SIV").text & ","
xParity = xParity & xmlNode.selectSingleNode("Parity").text & ","
xPremium = xPremium & xmlNode.selectSingleNode("Premium").text & ","
xIV = xIV & xmlNode.selectSingleNode("IV").text & ","
xLongPx = xLongPx & xmlNode.selectSingleNode("LongPx").text & ","
xPxChg = xPxChg & xmlNode.selectSingleNode("PxChg").text & ","
xTheoChg = xTheoChg & xmlNode.selectSingleNode("TheoChg").text & ","
xStubPrice = xStubPrice & xmlNode.selectSingleNode("StubPrice").text & ","
xShPxChgPer = xShPxChgPer & xmlNode.selectSingleNode("ShPxChgPer").text & ","
xSLH = xSLH & xmlNode.selectSingleNode("SLH").text & ","
xCurDelta = xCurDelta & xmlNode.selectSingleNode("CurDelta").text & ","
xImpDelta = xImpDelta & xmlNode.selectSingleNode("ImpDelta").text & ","
xTheoDelta = xTheoDelta & xmlNode.selectSingleNode("TheoDelta").text & ","
xFutHdg1 = xFutHdg1 & xmlNode.selectSingleNode("FutHdg1").text & ","
xImpVolCB = xImpVolCB & xmlNode.selectSingleNode("ImpVolCB").text & ","
xImpVolStub = xImpVolStub & xmlNode.selectSingleNode("ImpVolStub").text & ","
xV90D = xV90D & xmlNode.selectSingleNode("V90D").text & ","
xDPnL = xDPnL & xmlNode.selectSingleNode("DPnL").text & ","
xWPnL = xWPnL & xmlNode.selectSingleNode("WPnL").text & ","
xMPnL = xMPnL & xmlNode.selectSingleNode("MPnL").text & ","
xYPnL = xYPnL & xmlNode.selectSingleNode("YPnL").text & ","
xNetPnL = xNetPnL & xmlNode.selectSingleNode("NetPnL").text & ","
xDayTE = xDayTE & xmlNode.selectSingleNode("DayTE").text & ","


	
Next 
Set objXML = Nothing





aEnsembleID=split (xEnsembleID,",")
aIssue=split (xIssue,",")
aLongPos=split (xLongPos,",")
aStubPos=split (xStubPos,",")
aSIV=split (xSIV,",")
aParity=split (xParity,",")
aPremium=split (xPremium,",")
aIV=split (xIV,",")
aLongPx=split (xLongPx,",")
aPxChg=split (xPxChg,",")
aTheoChg=split (xTheoChg,",")
aStubPrice=split (xStubPrice,",")
aShPxChgPer=split (xShPxChgPer,",")
aSLH=split (xSLH,",")
aCurDelta=split (xCurDelta,",")
aImpDelta=split (xImpDelta,",")
aTheoDelta=split (xTheoDelta,",")
aFutHdg1=split (xFutHdg1,",")
aImpVolCB=split (xImpVolCB,",")
aImpVolStub=split (xImpVolStub,",")
aV90D=split (xV90D,",")
aDPnL=split (xDPnL,",")
aWPnL=split (xWPnL,",")
aMPnL=split (xMPnL,",")
aYPnL=split (xYPnL,",")
aNetPnL=split (xNetPnL,",")
aDayTE=split (xDayTE,",")



 

'Dim rst As New ADODB.Recordset'
Set objRs  = CreateObject("ADODB.recordset")

		
			
			
			objRs.Fields.Append "EnsembleID", adDouble, 100
			objRs.Fields.Append "Issue", adVarChar, 100
			objRs.Fields.Append "LongPos", adVarChar, 100
			objRs.Fields.Append "StubPos", adVarChar, 100
			objRs.Fields.Append "SIV", adDouble, 100
			objRs.Fields.Append "Parity", adDouble, 100
			objRs.Fields.Append "Premium", adDouble, 100
			objRs.Fields.Append "IV", adDouble, 100
			objRs.Fields.Append "LongPx", adDouble, 100
			objRs.Fields.Append "PxChg", adDouble, 100
			objRs.Fields.Append "TheoChg", adDouble, 100			
		objRs.Fields.Append "StubPrice", adDouble, 100
		objRs.Fields.Append "ShPxChgPer", adDouble, 100
		objRs.Fields.Append "SLH", adDouble, 100
		objRs.Fields.Append "CurDelta", adDouble, 100
		objRs.Fields.Append "ImpDelta", adDouble, 100
		objRs.Fields.Append "TheoDelta", adDouble, 100
		objRs.Fields.Append "FutHdg1", adDouble, 100
		objRs.Fields.Append "ImpVolCB", adDouble, 100
		objRs.Fields.Append "ImpVolStub", adDouble, 100
		objRs.Fields.Append "V90D", adDouble, 100
		objRs.Fields.Append "DPnL", adDouble, 100
		objRs.Fields.Append "WPnL", adDouble, 100
		   objRs.Fields.Append "MPnL", adDouble, 100
		   objRs.Fields.Append "YPnL", adDouble, 100
		   objRs.Fields.Append "NetPnL", adDouble, 100
		    objRs.Fields.Append "DayTE", adDouble, 100
	
		objRs.open, , 2, 3
		'objRs.Open , , adOpenStatic, adLockBatchOptimistic		
		For i = 0 To uBound(aEnsembleID) - 1
			objRs.AddNew 
			
			objRs.Fields("EnsembleID") = aEnsembleID(i)
			objRs.Fields("Issue") = aIssue(i)
			objRs.Fields("LongPos") = aLongPos(i)
			objRs.Fields("StubPos") = aStubPos(i)
			objRs.Fields("SIV") = aSIV(i)
			objRs.Fields("Parity") = aParity(i)
			objRs.Fields("Premium") = aPremium(i)
			objRs.Fields("IV") = aIV(i)
			objRs.Fields("LongPx") = aLongPx(i)
			objRs.Fields("PxChg") = aPxChg(i)
			objRs.Fields("TheoChg") = aTheoChg(i)
			objRs.Fields("StubPrice") = aStubPrice(i)
			objRs.Fields("ShPxChgPer") = aShPxChgPer(i)
			objRs.Fields("SLH") = aSLH(i)
			objRs.Fields("CurDelta") = aCurDelta(i)
			objRs.Fields("ImpDelta") = aImpDelta(i)
			objRs.Fields("TheoDelta") = aTheoDelta(i)
			objRs.Fields("FutHdg1") = aFutHdg1(i)
			objRs.Fields("ImpVolCB") = aImpVolCB(i)
			objRs.Fields("ImpVolStub") = aImpVolStub(i)
			objRs.Fields("V90D") = aV90D(i)
			objRs.Fields("DPnL") = aDPnL(i)
			objRs.Fields("WPnL") = aWPnL(i)
			objRs.Fields("MPnL") = aMPnL(i)
			objRs.Fields("YPnL") = aYPnL(i)
			objRs.Fields("NetPnL") = aNetPnL(i)
			objRs.Fields("DayTE") = aDayTE(i)
			
			
			
			
					
			objRs.Update()
		Next
		
			xsort = request.QueryString("sort")
			xSortID= request.QueryString("xSortID")
		
				if xSortID = "" then
				xSortID = " DESC"
				end if
				if xSortID = " DESC" then
				xSortID = " ASC"
				else
				xSortID = " DESC"
				end if
				
				
				'Response.Write xSortID
				objRs.Sort =  xsort & xSortID
%>

<table border="0" cellpadding="0" cellspacing="0" width="2250">
  <tbody>
    <tr>  
      <td width="50" height="25" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=EnsembleID&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">ID</a></div></td>
      <td width="160" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=Issue&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Issue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></div></td>
      <td  width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=LongPos&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">CB/Shr/Fut</a></div></td>
      <td width="100" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=StubPos&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stub&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></div></td>
      <td class="bcklghtblue" width="60"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=SIV&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">S/IV</a></div></td>
      <td width="60" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=Parity&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">Parity</a></div></td>
      <td width="60" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=Premium&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">Prem</a></div></td>
      <td width="60" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=IV&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">IV</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=LongPx&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">LongPx</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=PxChg&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">PxChg</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=TheoChg&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">TheoChg</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=StubPrice&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">Stub</a></div></td>
      <td class="bcklghtblue" width="85"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=ShPxChgPer&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">Sh%Day</a></div></td>
      <td  width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=SLH&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">% SLH</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=CurDelta&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">Delta</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=ImpDelta&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">ImpDel</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=TheoDelta&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">TheoDelta</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=FutHdg1&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">FutHdg1</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=ImpVolCB&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">ImpVolCB</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=ImpVolStub&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">ImpVolStub</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=V90D&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">V90D</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=DPnL&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">DPnL</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=WPnL&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">WPnL</a></div><td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=MPnL&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">MPnL</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=YPnL&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">YPnL</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=NetPnL&xSortID=<%=xSortID%>&xBookID=<%=xBookID%>" class="button">NetPnL</a></div></td>
      <td width="85" class="bcklghtblue"><div align="center" id="test"><a href="https://nwds.nimco.com.hk/dataGrid.asp?sort=DayTEC&xSortID=<%=xSortID%>&xBookID=N<%=xBookID%>" class="button">DayTE</a></div></td>
    </tr>
    <script  language="javascript" runat="server">
function jsproc(num1)
{
Response.Write("positive" & num1)
}
</script>
    <%
	
sub vbproc(num1, num2)


select Case num2
 
 Case "SIV"
    if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),3) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
	
		 Case "StubPos"
		   
		response.write "<span class='stubstyle'>" & formatnumber((num1),0) &  "</span>"
	
 
	 Case "LongPos"
			   
			  if num1>0 then
		response.write "<span class='stubstyle'>" & formatnumber((num1),0) &  "</span>"
	else
		response.write "<span class='stubstylegrey'>" & formatnumber((num1),0) &  "</span>"
	end if
 
 Case "Parity"
			    
		response.write "<span class='blackstyle'>" & formatnumber((num1),2) &  "</span>"
	
 Case "Premium"
				
		response.write "<span class='blackstyle'>" & formatnumber((num1),4)*100 &  "</span>"	
  Case "IV"
  if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
   Case "LongPx"
     if num1>0 then
		response.write "<span class='LongPx'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='LongPx'>" & num1 & "</span>"
	end if
    Case "PxChg"
	if num1>0 then
		response.write "<span class='npos'>+" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & formatnumber((num1),2) &  "</span>"
	end if
	 Case "TheoChg"
	 if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & formatnumber((num1),2) & "</span>"
	end if
	  Case "StubPrice"
	    	    if num1>0 then
		response.write "<span class='stub'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='stubstylegrey'>" & formatnumber((num1),2) &  "</span>"
	end if
	   Case "ShPxChgPer"
		   if num1>0 then
		response.write "<span class='npos'>+" & formatnumber((num1)*100,2) &  "%</span>"
		elseif num1=0 then
		response.write "<span class='stubstylegrey'>" & formatnumber((num1)*100,2) &  "%</span>"
		else
		response.write "<span class='nneg'>" & formatnumber((num1)*100,2) & "%</span>"
	end if
	    Case "SLH"
		varx = formatnumber((num1)*100,2)
			if varx=0 then
			response.write "<span class='stubstylegrey'>" & formatnumber((num1)*100,2) &  "%</span>"
		elseif varx>5 then
			response.write "<span class='wht'>+" & formatnumber((num1)*100,2) &  "%</span>"
		elseif varx<0 then
			response.write "<span class='nneg'>" & formatnumber((num1)*100,2) & "%</span>"
		else
			response.write "<span class='npos'>" & formatnumber((num1)*100,2) & "%</span>"
	   end if	
		 Case "CurDelta"
		 if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "%</span>"
	else
		response.write "<span class='nneg'>" & formatnumber((num1),2) & "%</span>"
	end if
		  Case "ImpDelta"
		  if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
		   Case "TheoDelta"
		   if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & formatnumber((num1),2)*100 & "</span>"
	end if
		    Case "FutHdg1"
			if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
			 Case "ImpVolCB"
			 if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
			  Case "ImpVolStub"
			  if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
			   Case "V90D" 
			   if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
			    Case "DPnL"
				if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
				 Case "WPnL"
				 if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
				  Case "MPnL"
				  if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
				   Case "YPnL"
				   if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
				     Case "NetPnL"
					 if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
					   Case "DayTE"
					   if num1>0 then
		response.write "<span class='npos'>" & formatnumber((num1),2) &  "</span>"
	else
		response.write "<span class='nneg'>" & num1 & "</span>"
	end if
				
	
end select


end sub




%>
    <%

  
  
  objRs.movefirst
  do while not objRs.eof
  
	 
	 %>
    <tr>
      <td><div align="center" class="bcklghtblue"><%Response.write left(objRs("EnsembleID"),15)%></div></td>
      <td><div align="left" style="padding-left:5px"  class="stubstyleborder"><%Response.write left(objRs("Issue"),15)%></div></td>
      <td bgcolor="f2f2f2"><div align="center"><%call vbproc(objRs("LongPos"), objRs("LongPos").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("StubPos"), objRs("StubPos").name)%></div></td>
      <td><div align="center" class="stubstyleborder"><%call vbproc(objRs("SIV"), objRs("SIV").name)%></div></td>
      <td><div align="center" class="blackstyle"><%call vbproc(objRs("Parity"), objRs("Parity").name)%></div></td>
      <td><div align="center" class="blackstyle"><%call vbproc(objRs("Premium"), objRs("Premium").name)%>%</div></td>
      <td><div align="center"><%call vbproc(objRs("IV"), objRs("IV").name)%></div></td>
      <td  bgcolor="f2f2f2"><div align="center"><%call vbproc(objRs("LongPx"), objRs("LongPx").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("PxChg"), objRs("PxChg").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("TheoChg"), objRs("TheoChg").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("StubPrice"), objRs("StubPrice").name)%></div></td>
      <td><div align="center" class="stubstyleborder"><%call vbproc(objRs("ShPxChgPer"), objRs("ShPxChgPer").name)%></div></td>
      <td class="<%if formatnumber(objRs("SLH")*100,2) > 5 then
	  					response.write "SLH"
	 				 end if%>"><div align="center"><%call vbproc(objRs("SLH"), objRs("SLH").name)%></div></td>
      <td><div align="center" class="stubstyleborder"><%call vbproc(objRs("CurDelta"), objRs("CurDelta").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("ImpDelta"), objRs("ImpDelta").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("TheoDelta"), objRs("TheoDelta").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("FutHdg1"), objRs("FutHdg1").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("ImpVolCB"), objRs("ImpVolCB").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("ImpVolStub"), objRs("ImpVolStub").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("V90D"), objRs("V90D").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("DPnL"), objRs("DPnL").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("WPnL"), objRs("WPnL").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("MPnL"), objRs("MPnL").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("YPnL"), objRs("YPnL").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("NetPnL"), objRs("NetPnL").name)%></div></td>
      <td><div align="center"><%call vbproc(objRs("DayTE"), objRs("DayTE").name)%></div></td>
    </tr>
    <%objRs.MoveNext
			Loop
			%>
  </tbody>
</table>
</body>
</html>

Open in new window

0
 
ste5anSenior DeveloperCommented:
You have to choices:

1) Use a more modern approach. Thus using an AJAX call to the XML file and handling the data in JavaScript. If you don't use complex ASP components, then this would be my favorite.

2) Using the classic approach: your doubts are correct. It's normally not necessary unwrap XML first, just to create a record set from it. But you have a reason for it: You want to apply a custom sort order to it. Thus without to much fiddling, I would take a look at the XML and the feature of ADO to load XML directly. As your XML row node is named Data, it's possible that this is already doable without much hassle. Can you post a XML sample?
0
 
nthawkins1971Author Commented:
sure... the list goes on for up to 5000+ lines but here's a snippet... the EnsembleId, Bookcode change for each... thanks

<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="../NWP-MV.asp?sortBy=EnsembleID"?>
<DocumentElement>
<Data>
<EnsembleID>987654321</EnsembleID>
<BookCode>NNNNN</BookCode>
<Issue>Company Name</Issue>
<LongPos>0</LongPos>
<StubPos>800000000</StubPos>
<SIV>0.982</SIV>
<Parity>97.5</Parity>
<Premium>0.118</Premium>
<IV>99.29</IV>
<LongPx>109.01</LongPx>
<TheoVal>107.848985399206</TheoVal>
<PxChg>0.48</PxChg>
<TheoChg>0.351152</TheoChg>
<StubPrice>9.71</StubPrice>
<ShPxChgPer>0.011354</ShPxChgPer>
<SLH>0.0699</SLH>
<CurDelta>0.321</CurDelta>
<ImpDelta>0.5</ImpDelta>
<TheoDelta>0.495</TheoDelta>
<FutHdg1>-14.02</FutHdg1>
<ImpVolCB>0.223</ImpVolCB>
<ImpVolStub>0.224</ImpVolStub>
<V90D>0.199</V90D>
<DPnL>5.6</DPnL>
<WPnL>-3</WPnL>
<MPnL>-0.2</MPnL>
<YPnL>6.4</YPnL>
<NetPnL>33.6</NetPnL>
<DayTE>0.03554</DayTE>
</Data>
<EnsembleID>123456789</EnsembleID>
<BookCode>XXXXXX</BookCode>
<Issue>Company Name</Issue>
<LongPos>0</LongPos>
<StubPos>800000000</StubPos>
<SIV>0.982</SIV>
<Parity>97.5</Parity>
<Premium>0.118</Premium>
<IV>99.29</IV>
<LongPx>109.01</LongPx>
<TheoVal>107.848985399206</TheoVal>
<PxChg>0.48</PxChg>
<TheoChg>0.351152</TheoChg>
<StubPrice>9.71</StubPrice>
<ShPxChgPer>0.011354</ShPxChgPer>
<SLH>0.0699</SLH>
<CurDelta>0.321</CurDelta>
<ImpDelta>0.5</ImpDelta>
<TheoDelta>0.495</TheoDelta>
<FutHdg1>-14.02</FutHdg1>
<ImpVolCB>0.223</ImpVolCB>
<ImpVolStub>0.224</ImpVolStub>
<V90D>0.199</V90D>
<DPnL>5.6</DPnL>
<WPnL>-3</WPnL>
<MPnL>-0.2</MPnL>
<YPnL>6.4</YPnL>
<NetPnL>33.6</NetPnL>
<DayTE>0.03554</DayTE>
</Data>

</DocumentElement>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.