Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Modifying Processing Line Done, but wrong way

    I've a problem now. I noticed i've programmed the wrong thing.

    My ASP Script(part of it)

    XMLfilesrc = Request.Form("xmlfileid")
    XSLfilesrc = Request.Form("xslfileid")


    'Creating a NodeList of the elements in the XML Tree
    Set objNodeList = objDom.documentElement.childNodes


    'Loop through each item in the NodeList and check if its NodeType is that of a Processing Instruction i.e.
    Dim hrefsrc
    hrefsrc="href=""" &XSLFilesrc +""""

    for i = 0 to objNodeList.length-1
    If objNodeList.item(i).nodeType = 7 then
    set objNewPI = objDom.createProcessingInstruction("xml-stylesheet"," ")
    objdom.documentElement.appendchild objnewpi
    objNewPI.data = "type=""text/xsl"" " +hrefsrc
    ' objdom.documentElement.replaceChild objNewPI, objNodeList.item(i)
    objdom.documentElement.replaceChild objNewPI, objDOM.childNodes(0)

    End If
    next

    This works perfectly and it does modify the processing line my xml file. But This only modify the processing instruction in the element node list. (which is in <text></text>

    (XML that is modifled)
    <?xml version="1.0"?>
    <text>
    <?xml-stylesheet type="text/xsl" href="aflooding.xsl"?>
    <title>Adaptive Flooding</title>
    <s-title>Adaptive Flooding</s-title>
    </text>

    What i wanted was to put it after <?xml version="1.0">
    so that i can run the xml file which will display according to the stylesheet after i use this asp to modify. Because currently it is inside <text></text> which i can output it with explorer just by double clicking. I've no idea how to do it out of the element list. Hope anyone can answer me..
    Thanks.

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    I think I can help you.

    You currently write:

    objdom.documentElement.replaceChild objNewPI, objDOM.childNodes(0)

    I take it objdom is the document node. In that case, you can write:

    objdom.insertBefore(objNewPI, objdom.documentElement)

    That should work. Of course, I've never coded ASP before.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

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