Link to home
Start Free TrialLog in
Avatar of TrueBlue
TrueBlueFlag for United States of America

asked on

need to transform xml into visual sitemap


Any specific code would be appreciated in converting XML sitemap into visual HTML sitemap.
I guess XSLT would be the best way.
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

This is all the XSLT you need
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
    xmlns:xd="" version="1.0">
    <xsl:output method="html" indent="yes"/>
    <xsl:strip-space elements="*"/>
<xsl:template match="urlset">
            <xsl:apply-templates select="url">
                <xsl:sort select="priority" order="descending" data-type="text"/>
    <xsl:template match="url">
             <a href="{loc}">
                <xsl:value-of select="loc"/>

Open in new window

Avatar of TrueBlue


Thank you for the XSLT.
Any idea why this is not displaying anything?

      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
       Response.Write "Could Not Retrieve SiteMap.xsl stylesheet"
end if %>

I think I have the ASP fixed, but no data is being displayed.
Will this XSL run using the MSXML 6 processor?
THis will run fine on any XSLT processor.
msxml6 will be fine, but make sure you have msxml6 isntalled, since you point to it directly

I don't like this
    'xmlResponse = Replace(xmlResponse, "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""utf-8""?>")
there is no need to add UTF_8 there since it is teh default
and you seem to cast an xml object to a string

you might need some debugging since you need to check wheiter XSLT and XML are all loaded correctly

and of course, I don't know whether your XML sitemap has a namespace

I think I fixed most of the aforementioned items you, except for the namespace.
Any suggestions as to the proper namespace for this xml page?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial