Results 1 to 3 of 3

Thread: XML attributes using JS code

  1. #1
    Join Date
    Jan 2005

    XML attributes using JS code

    in my xml page i have the following elements

    <title>Hello World</title>
    <category type="cool" />

    I know i can use this line of code

    var title = $(this).find('title').text();

    to access the text between the title tags but i dont know how to access the attribute of the category tag.

    i have tried this

    var catType = $(this).find('category').attr('type');

    but that doesn't work...

    does anyone know the syntax to access the attribute.


  2. #2
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    That is not JavaScript native code. You must specify which kind of javascript library/framework you use. JQuery? Prototype? MooTools? Other?...

    Don't confound javascript language with javascript library. Javascript libraries are written in javascript but they invent and use custom methods, impossible to recognize from those who do not know their documentation.

    On the other hand when dealing with XML objects it is better to use XML DOM and plain javascript codes, not a library.
    Last edited by Kor; 12-04-2009 at 04:21 AM.

  3. #3
    Join Date
    Jan 2005
    i am using jquery...i think...

    to be honest i dont really know what i am doing with the code i am utilising. More of a guess and check method to getting what i want...hacking if you will.

    I dont really understand how to get what i want from an xml...none the less i dont have time to really understand it at this point.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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