Wednesday, May 2, 2012

Search an XML file using Javascript then retrieving specific attributes based on matched string

I've looked through this entire site as various ways in searching through an XML file using a value taken from a html input field and have managed to do this, however when it finds the match thats all I can do is display a message saying "Match Found!".

What I'd like to do is be able to search the XML file using the search string value put into the html input field, then once its found a match pull the rest of the information for that specific node - as in all the attributes.

Example of my XML file:

<dvd year="1979" rating="18" director="ridley scott">Alien</dvd>

The title of the film being "Alien" so that would be the search string.

Any ideas how this could be done? I'm guessing it has something to do with loading into a javascript array maybe. Just to make anyone who answers aware none of the examples I've seen thus far have been that clear on the exact code that would achieve this.

Thanks in advance for the help!!

No comments:

Post a Comment