Solved

Vbscript not displaying links

Posted on 2011-02-16
11
838 Views
Last Modified: 2012-08-13
Hi!

The below listed vbscript on an ASP page is not giving me any errors, but it also is not displaying the links from our XML page using the XSL page to render it. Any specific code corrections would be greatly appreciated.

<%
      Dim NewXML, re, oXmlSrc, oXml, oNode, oXslSrc, oXsl, oXslTemplate
     
      ' If you're using an XSLTemplate and XSLProcessor object,
      '   you have to use the FreeThreaded versions of DOMDocument
      Set oXmlSrc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
      Call oXmlSrc.setProperty("ServerHTTPRequest", True)            
      oXmlSrc.async = False
     
      Set oXslSrc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
      Call oXslSrc.setProperty("ServerHTTPRequest", True)            
      oXslSrc.async = False
     
      Set oXslTemplate = Server.CreateObject("MSXML2.XSLTemplate.4.0")

      ' If I haven't posted the form first, then load my unaltered XML.
      ' If I'm posting info to resort or edit, then build my XML from that.
     
    ' On Error Resume Next  'debugging code if table does not appear uncomment this line

      'xmlResponse = Replace(xmlResponse, "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""utf-8""?>")

            'Call oXmlSrc.loadXML (xmlResponse)      
            Call oXmlSrc.load (Server.MapPath("sitemap.xml"))
          'Response.Write "<xmp>" & oXmlSrc.xml & "</xmp>"    'debugging code
          'newXML = oXmlSrc.xml
        'Set re = new regexp
        're.pattern = " xmlns.+?>"
        'newXML = re.replace(newXML,">")
        'Call oXmlSrc.loadXML(newXML)
  if oXslsrc.load (Server.MapPath("sitemap.xsl")) then
     Set oXslTemplate.stylesheet = oXslsrc
     Set oXslProcessor = oXslTemplate.createProcessor()
     oXslProcessor.input = oXmlsrc
     Response.Write oXmlsrc
    else
       Response.Write "Could Not Retrieve SiteMap.xsl stylesheet"
end if %>
0
Comment
Question by:TrueBlue
  • 6
  • 5
11 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 34911778
It might be because you're loading the XML file twice.  Comment out this line:
            Call oXmlSrc.load (Server.MapPath("sitemap.xml"))

because this line
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then

will also load it.

Also, do you get any output if you change this:
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then

to this
  Response.Write "Loading xml...<BR>"
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then
     Response.Write "XML loaded...<BR>"


Regards,

Rob.
0
 

Author Comment

by:TrueBlue
ID: 34912173
Rob,

I did as you suggested and it returned the following ...

Loading xml...
XML loaded...
Response object error 'ASP 0185 : 80020003'
Missing Default Property
/sitemap.asp, line 0
A default property was not found for the object.

Any ideas?
TIA
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34912513
Should this line:
     Response.Write oXmlsrc

be this:
     Response.Write oXmlsrc.xml

It looks like the Response object error that you are getting is due to this:
     Response.Write oXmlsrc

and oXmlsrc is an object, so you can't output it, you need to reference one of its (string) properties.

Rob.
0
 

Author Comment

by:TrueBlue
ID: 34912990
Rob,

That fixed the error.
Now it displays the following...
Loading xml...
XML loaded...

But, no links are displayed.
Any other ideas?

TIA
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34913020
Does it display any xml from the sitemap.xml?

What is the format of your xml? We might need to read the xml nodes to be able to output them.

Rob.
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:TrueBlue
ID: 34920776
Rob,
The XML looks fine when I look at the page using IE.

Here is the XML:
http://www.topsecurityinc.com/sitemap.xml
Here is the XSL:
http://www.topsecurityinc.com/sitemap.xsl

Any suggestions would be appreciated.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34921203
OK, I'll see if I can run some tests with it.  So do you want the entire xml to be output to the page?

Rob.
0
 

Author Comment

by:TrueBlue
ID: 34921448
Rob,

I am basically trying to make a people friendly sitemap using the XML file.

TIA
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34922986
Hi, isn't it is possible to point your XML file to use the XSL directly, by adding something like this:
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>

And then display the xml in the browser?

Regards,

Rob.
0
 

Author Comment

by:TrueBlue
ID: 34927487
Rob,

Wouldn't this method negate the ability of search engines being able to properly read the sitemap for indexing purposed?

TIA
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34931797
It would if you had it processed client side.  It looks like if you process it server side, then Google would index the processed page.

See if this gives you any more information:
http://msdn.microsoft.com/en-us/magazine/bb984985.aspx

Regards,

Rob.
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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

12 Experts available now in Live!

Get 1:1 Help Now