Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Editing XML using XSL & ASP Problem

  • 06-07-2009 2:55pm
    #1
    Closed Accounts Posts: 408 ✭✭


    Hello All,

    I've a brief question regarding adapting a tutorial I found relating to the above topic title.
    Link

    I'll admit i'm pretty "new" when it comes to coding in asp, and also XML DOM structures.

    I have adapted the above tutorial to function with the following xml document:
    <applicants>
    <applicant>
    <appid>001</appid>
    <firstname>Joe</firstname>
    <surname>Bloggs</surname>
    <age>25</age>
    <gender>Male</gender>
    </applicant>
    </applicants>
    

    Although inside the EditContact.asp file (as named in the above link) there is a line of code that is preventing me from exporting the changes made in my form (xsl styled) to the above xml file.

    The code is (complete with comments):
     'Set objField variable equal to a field_value element by
       'calling the selectSingleNode method of the objRoot
       '(documentElement) object.  The SelectSingleNode method
       'accepts a string parameter for querying the XML document.
       'In this case, the current value of the key property of
       'the Form Collection is used to find the appropriate
       'field_value element (more on this later).
       Set objField = objRoot.selectSingleNode("field[@id='" & _
       Request.Form.Key(x) & "']/field_value")
    

    The basic problem I'm having is changing the "field[@id&quot; part to reflect my elements appid, firstname, surname etc. without the need for attaching attributes to my xml file.

    I've read up on selectSingleNode() function, and tried a few alternatives such as:
    selectSingleNode(//applicant.childNodes[x]) 
    selectSingleNode(/applicants/applicant.childNodes[x].nodeName)
    

    I may be way off the beaten track, so apologies if i am...oh and I did change the "field_value" variable to .text / .nodeValue / .value with no luck either....

    Could anyone give me a clue as to where i'm going wrong? I'm dreading its something really simple that I couldnt find googling it for the most of today :<


    *UPDATE*

    I've come up with this:
    Set objField = objRoot.selectSingleNode("applicants/applicant/[*='" & _
       Request.Form.Key(x) & "']/text()")
    

    I know that the "applicants/applicant/*" selects all the child elements of applicant which is what i want - but I'm still having trouble getting the changes i make to be saved to my applicants.xml file.

    I'll keep fiddling with it - but in the mean time if anyone has any pointers please fire them up for me!

    *UPDATE*


    Many thanks,

    Dan


Advertisement