Results 1 to 5 of 5

Thread: Merge XML and XSL with ASP

  1. #1
    Join Date
    Apr 2006
    Location
    Amsterdam
    Posts
    352
    Thanks
    20
    Thanked 11 Times in 11 Posts

    Default Merge XML and XSL with ASP

    My problem is that I want to sort some nodes of a XML file I have and use asp to convert it to html. I'm also using a XSL template to sort the XML node results, since there no way (to my knowledge) to sort XML nodes other then by use of XSL.

    The reason I’m using ASP to convert the results to HTML, instead of using the XSL file directly with XML is because I would like to edit/alter some of the results.

    I’ve been using this script which helped me in the right direction (I think).

    Code:
    Dim objXML
    Dim objXSL
    Dim strHTML
     
    'Load the XML File
    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    objXML.async = False
    objXML.load(Server.MapPath("xmlxsl.xml"))
     
    'Load the XSL File
    Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
    objXSL.async = False
    objXSL.load(Server.MapPath("xmlxsl.xsl"))
     
    ' Transform the XML file using the XSL stylesheet
    strHTML = objXML.transformNode(objXSL)
     
    Set objXML = Nothing
    Set objXSL = Nothing
     
    ' Spit out the resulting HTML... the data comes from the
    ' .xml file, but the formatting of the results depends
    ' completely upon the .xsl file.
    Response.Write strHTML
    But this script doesn’t allow me to edit/alter the results before they are spited out as HTML.

    Any suggestions on how to approach??

  2. #2
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Why cant you use objXML to edit the XML data?
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Apr 2005
    Location
    Haslemere, Surrey, UK
    Posts
    340
    Thanks
    5
    Thanked 3 Times in 3 Posts

    Default

    Try this. I just hand wrote it so their may an error or 2 in it. But it should work.
    Dim objXML
    Dim objXSL
    Dim strHTML

    'Load the XML File
    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    objXML.async = False
    objXML.load(Server.MapPath("xmlxsl.xml"))

    'Load the XSL File
    Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
    objXSL.async = False
    objXSL.load(Server.MapPath("xmlxsl.xsl"))

    ' Transform the XML file using the XSL stylesheet
    Set objResult = Server.CreateObject("Microsoft.XMLDOM")
    objResult.async = False
    objResult.validateOnParse = false

    objXML.transformNodeToObject(objXSL,objResult)

    ' Now edit the objResult


    Alastair - WOWD



  4. #4
    Join Date
    Apr 2006
    Location
    Amsterdam
    Posts
    352
    Thanks
    20
    Thanked 11 Times in 11 Posts

    Default

    Quote Originally Posted by Warren Ashcroft
    Why cant you use objXML to edit the XML data?
    I would love to use objXML to edit the data, but i also need de XSL (i think) to sort the data.

    Quote Originally Posted by Wise Webs
    ....
    Microsoft VBScript compilation error '800a0414'


    Cannot use parentheses when calling a Sub
    /xml/test.asp, line 14

    objXML.transformNodeToObject(objXSL,objResult)
    ----------------------------------------------^

    I'am not sure what to make of this error, there is not much of a Sub.
    Any clue on this one?

  5. #5
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Change
    Code:
    objXML.transformNodeToObject(objXSL,objResult)
    To
    Code:
    objXML.transformNodeToObject objXSL, objResult
    You only use (parantheses) when the call returns data and you want to use it, IE:

    Code:
    variable = objXML.transformNodeToObject(objXSL,objResult)
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. XML/XSL date format
    By Rappie in forum XML
    Replies: 1
    Last Post: 27th July 2006, 12:10 PM
  2. XMl/XSLT/CSS Sitemap
    By jaimalchohan in forum XML
    Replies: 3
    Last Post: 28th February 2006, 10:18 AM
  3. Re: Catution when using XML for Logic
    By jaimalchohan in forum ASP.NET
    Replies: 3
    Last Post: 25th November 2005, 04:44 PM
  4. XSL transformation in PHP
    By robgallen in forum PHP
    Replies: 5
    Last Post: 13th October 2005, 08:17 AM
  5. Use any diff/merge utilities?
    By terraqueotenaz in forum Development Support
    Replies: 4
    Last Post: 28th June 2005, 09:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •