0

Hi,

I have a Javascript function that creates an Ajax request, returning an XML document into transport.responseXML . I want to process this document but without hardcoding each tag name i.e. xmlOptions[0].getElementsByTagName('salary')[0].firstChild.data . I would like to iterate over the XML document and find each tag and its value. The XML document I want to process is structured as such:

<job>
   <contactTelephone>028 ---------</contactTelephone>
   <contactName>Karen -------</contactName>
   <contactFax>028 -----------</contactFax>
   <contactEmail>karen@---------</contactEmail>
   <contactWebsite>www.---------</contactWebsite>
   </job>

Thanks,

Sean

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by stymiee
0

Just loop through the array like you would any other array. See that zero? It can be a variable, too.

for (var i = 0; i <  xmlOptions[0].getElementsByTagName('salary').length; i++)
{
     document.write(xmlOptions[0].getElementsByTagName('salary')[i]);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.