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 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post

    Javascript and XML

    So I'm having an issue I need to work with an xml file, personally I don't like how it's laid out but I have no choice but to use it there's no changing it. Anyways I need to pull out certain values such as:

    <RECORDS>
    <RECORD>
    <ROW
    NAME="SOMETHING"
    AMOUNT="24.50"
    QUANTITY="10"
    OPERATIONDATE="20101108"
    />
    </RECORD>
    </RECORDS>

    Anyways I am unable to access it using getElementsByTagName("ROW")[0].childNodes[0].nodeValue;
    I'm sure it's something stupid I'm missing but I need to access the amount value. Any help would be much appreciated.

  • #2
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post
    Anyone?

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post
    Well for anyone that's interested what I was missing was getElementsByTagName("ROW").getAttribute("AMOUNT");
    searched for 2 days for that lol

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Not exactly. getAttribute() is rather an HTML DOM method. XML DOM has another syntax:
    Code:
    getElementsByTagName("ROW").getAttributeNode("AMOUNT").nodeValue
    It is true: both methods are, more or less inter-changeable between HTML and XML (especially in case of XHTML Doctyped documents), but it is wiser to use the proper method for the proper scope
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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