Solved

ASP - SelectNodes - Error on Transform

Posted on 2011-02-21
8
878 Views
Last Modified: 2012-05-11
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
Comment
Question by:Cmedic_techs
  • 5
  • 3
8 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34944016
You're trying to call transformNode on an IXMLNode object, which is invalid. You have to call it on the Document object itself.
0
 

Author Comment

by:Cmedic_techs
ID: 34944179

 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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34944622
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
 

Author Comment

by:Cmedic_techs
ID: 34944981
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Cmedic_techs
ID: 34945013
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
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34945110
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
 

Author Comment

by:Cmedic_techs
ID: 34945499
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
 

Author Closing Comment

by:Cmedic_techs
ID: 34945506
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Disable and re-enable a dynamic System.Timers.Timer 6 40
Achieve json result 2 65
Adjust the position 3 49
Need a starter for ETL protocol? 4 42
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now