Finding an element based on other element in XML

May 5 2006 5:03 AM
Hi,

i have an xml file as follows:

1.       <?xml version=”1.0” encoding=”UTF-8” standalone=”yes”?>

2.       <COLLECTION>

3.          <CD>

4.             <ARTIST>Queen</ARTIST>

5.             <TITLE>A Night at the Opera</TITLE>

6.             <YEAR>1975</YEAR>

7.          </CD>

8.          <CD>

9.             <ARTIST>Queen</ARTIST>

10.         <TITLE>A Day at the Races</TITLE>

11.         <YEAR>1975</YEAR>

12.      </CD>

13.   </COLLECTION>


i want to if i given an argument, say "ARTIST" element - "Queen", i shud get the value of the "TITLE" element associated with it, i.e. "A Night at the Opera".

Please let me the code of how to go about it... ( i m currently using GetElementsByTagName to get the value)


Answers (3)