Solved

Vbscript not displaying links

Posted on 2011-02-16
11
843 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
modifying VBScript to VBA 17 89
Making Table Thru ASP Response.write 5 37
SQL Query Returns Records in SSMS but not Classic ASP 5 46
Compress Newid value ms sql Mssql 4 46
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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