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 6 of 6
  1. #1
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading the values of XML tag attributes

    I've been to www.youngpup.net (this guy is brilliant!). Anyways, I was reading some of his content which is in XML files, and noticed that he had a script there somewhere that was able to read and display the value of an attribute in an XML tag. I looked through his source code, and didn't see it, although obviously, it was there somewhere... I just must have missed it.

    Anyways, does anyone know of a cross-platform way of reading these attributes?

    Thanks
    -- Sky

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #2
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm going to bump this thread, k?

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    assuming you're talking XSL ...


    <xsl:value-of select="node" />

    <xsl:value-of select="@attribute" />



    You can add node/attribute values into other strings like

    <a href="{url}">

    or

    <a href="{@url}">



    I think that's right

  • #4
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's good, but I'm looking for a JavaScript way to do it. I know that HTML tag attributes can be read with getAttribute(), but I wasn't sure if a similar way could be used for XML.

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #5
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    The getAttribute() method of Element is a DOM Core method; it will work from XML. The key is for the document to recognize your script element in the first place:

    <script xmlns="http://www.w3.org/1999/xhtml" type="application/x-javascript"><![CDATA[
    // script here
    ]]></script>
    "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

  • #6
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You've been a tremendous help. I appreciate it!

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.


  •  

    Posting Permissions

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