XML Attribute Question

I have a xml file like this...
<?xml version="1.0" encoding="utf-8" ?>
  <partialRates rate1="18 cents" rate2="16 cents" rate3="8 cents" rate4="9 cents" rate5="10 cents"></partialRates>

Is there a DOM function to get the number of elements in the attribute "partialRates" ?

What I need is ... there are 5 rates in the above line. I want a javascript function to return
Who is Participating?
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
the attributes collection has the length property
RobOwner (Aidellio)Commented:
as angelIII said: use the length.  Sample javascript you could use:

// get the tag - iif you add a class or id you could get a specific tag
// this gets the first one matched.

var rates = document.getElementsByTagName('partialRates ')[0];
var length = rates.attributes.length;  // this returns 5
prainAuthor Commented:
Thanks. Great!.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.