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
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    retrieving node attribute values from XML file

    hell I am trying to retrieving a nodes attributes.. but am failing..

    for example I have this XML

    <description>

    <attribute id="2" name="Colour">
    <value id="212">red/pink</value>
    </attribute>

    </description>

    I am trying to retrieve the value inside the nodes.. for example... 212 from id ans also 2 from attribure id ..

    I am using Set xml = Server.CreateObject("Microsoft.XMLDOM") to connect to the xml... and this is fine..

    i can pull out the tag values fine.. for example red/pink using
    colours = xml.documentElement.childNodes(0).childNodes(1).childNodes(0).text

    I have tried everything to get the id values and it is stumping me.. also i don't want to use xsl or go external of my asp page....

    any help would be great

    cheers chris
    <marquee>thanks</marquee>

  • #2
    Regular Coder
    Join Date
    May 2007
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 18 Times in 18 Posts
    For this XML:
    Code:
    <description>
        <attribute id="2" name="Colour">
            <value id="212">red/pink</value>
        </attribute>
    </description>
    code:
    Code:
     
    Set x = Server.CreateObject("MSXML.DOMDocument")
    x.load(Server.MapPath("x.xml"))
    Response.Write x.documentElement.childNodes(0).childNodes(0).text
    Response.Write "<br />"
    Response.Write x.documentElement.childNodes(0).childNodes(0).GetAttribute("id")


  •  

    Posting Permissions

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