• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 896
  • Last Modified:

ASP - SelectNodes - Error on Transform

I am attempting to do a transform through ASP on some XML, then use an Xsl file to output the data.

I have to do selectNodes, so that I can dynamically change the "source" that I am searching on.
otherwise I would do it inside the XSL.

First code snippet is xmlretrieve.asp
step one, I retrieve a token from the api from appshore.net
I then insert that token into a url string, to retrieve the actual data I want to manipulate.
I then load it as an xmldom, and view the data without parsing it.  This works fine, and will output as expected. ' I did this for testing purposes
however when I then do a selectnodes on it.
and then attempt the transform, I get the following error.
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'transformNode'
/xmlretrieve.asp, line 106


any thoughts?

 
<%
Response.Expires = -1
Dim Token
token= "https://hawkeyemgmt.appshore.net/xml.php?&op=base.auth.login&user_name=Unassigned&user_password=guest1234" 

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.Open "GET", token, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText

Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False

If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If

Set TokenGet = xmlDOM.getElementsByTagName("sid")
TokenGetCount = TokenGet.Length-1

For i = 0 To TokenGetCount
Set TokenGet = TokenGet.Item(i)
next


for each child in TokenGet.childNodes

TokenAuth = child.text
next


dim urlrequest
dim status2
dim strEMail
Dim objXML
Dim objNode
Dim objXSL

urlrequest= "https://hawkeyemgmt.appshore.net/xml.php?&sid=" & TokenAuth & "&op=leads.retrieve"
xmlhttp.Open "GET", urlrequest, false
xmlHttp.Send()
If xmlHttp.Status = 200 Then
    Set oResponseXML = xmlHttp.ResponseXML 'Save XML to an object
	
    bXMLLoadError = False
	Else
	 Response.Write("status="&xmlhttp.status & "<br>")
	Response.Write("<font color=""red"">Page Error: unknown Could not load XML from remote server</font><br>") 
	 
	 bXMLLoadError = True
End If


Set xmlHttp = Nothing ' clear HTTP object

%>

<%
'Initialise variables
' Attempting to actually retrieve the leads at this point.
Dim oXMLHTTP
Dim oResponseXML
Dim bXMLLoadError
Dim whoIwant

%>
<%

If Not bXMLLoadError Then

    'Load the XML from the oResponseXML object
    set oXML = Server.CreateObject("Microsoft.XMLDOM")
    oXML.Async = false
    oXML.Load(oResponseXML)

Set objNode = oXML.SelectNodes("API/leads/leads_item[source_id='Other']") ' at least four records contain Other

    'Load the XSL from disk   
  
   set oXSL = Server.CreateObject("Microsoft.XMLDOM")
   	
   oXSL.Async = False
  
   oXSL.Load(Server.MapPath("leads_retrieve.xsl"))
  ' This works as long as the other transform is commented out.
  Response.Write(oXML.transformNode(oXSL)) 'Transform the XML using the XSL stylesheet 

set oXSL2 = Server.CreateObject("Microsoft.XMLDOM")
 
 If objNode.length > 1 Then ' test to see if obj.Node has any data in it.

  set oXSL2 = Server.CreateObject("Microsoft.XMLDOM")
   	
   oXSL2.Async = False
  
   oXSL2.Load(Server.MapPath("leads_retrieve2.xsl")) ' customized XSL file for the transofrm

   ' I have tried this  no go text not support
'For Each Node In objNode
'Document.Write(objNode.text) & "<br />" 
'Next
'

 Response.Write(objNode.transformNode(oXSL2)) 'Transform the XML using the XSL stylesheet

 Response.Write("I got to here") ' step over test

 Else

 Response.Write("No Leads to Return")
 End If

  
End If

%>

Open in new window

<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="leads_xml.xml" -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="API/leads">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Leads Retrieve NodeSelect</title>
</head>
<body>
<table border="1">
<tr bgcolor="#eeeeee">
<th align="left">Account Name</th>
<th align="left">source_id</th>
</tr>
<xsl:for-each select="leads_item">
<tr>
<td><xsl:value-of select="account_name"/></td>
<td><xsl:value-of select="source_id"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Open in new window

0
Cmedic_techs
Asked:
Cmedic_techs
  • 5
  • 3
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
You're trying to call transformNode on an IXMLNode object, which is invalid. You have to call it on the Document object itself.
0
 
Cmedic_techsAuthor Commented:

 Response.Write(objNode.transformNode(oXSL2)) 'Transform the XML using the XSL stylesheet

the document object being?  I'm sorry but little new to this, I've slowly built this through various examples out there on the web, and I'll admit, I have not reached full comprehension yet.
0
 
Carl TawnSystems and Integration DeveloperCommented:
oXML is the document object which holds your XML.
oXSL is also a document object, which in your code holds your XSL document.

SelectSingleNode and SelectNodes both return node objects, which represent elements within the document, rather than the whole document itself.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Cmedic_techsAuthor Commented:
Alright that makes sense, so now I will research based on that, and see if I can figure out how to transform after a SelectNodes is used.

cross your fingers, I've been trying to get past this point for over ten hours already.
0
 
Cmedic_techsAuthor Commented:
Set objNode = oXML.SelectNodes("API/leads/leads_item[source_id='Other']")

I need to output this result, hopefully using a xsl stylesheet.
as embededd above.
0
 
Carl TawnSystems and Integration DeveloperCommented:
You don't need to do a SelectNodes call first. The XSL Transform acts on the whole document. If you want to filter and only display certain elements from your XML document then you need to build that logic into your transform.
0
 
Cmedic_techsAuthor Commented:
anyhow.  I'm going to give you the points.  since you responded. and I didn't clarify why I needed to do the SelectNodes in the manner that I was.

but what I was trying to accomplish, is this, and I'm terrible sometimes at writing this out.

client logins.
retrieve leads from remote api in xml format.
select only those leads_items that correspond to that client.
output in a table, the data in that node.
since I can't put asp in the xsl.
I had act on the data prior to the xsl.

I have since found another way to do it that is working.  so thanks anyways.

0
 
Cmedic_techsAuthor Commented:
it wasn't actually a solution, it was more a what you were doing wrong, without an example of what to do to resolve it
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now