I am very new to using XML and I have what should be an easy solution but google is failing me. I have one xml document with different data sets in it (see code below). What I want is to only work with one set of data at a time.
Here is a sample XML doc:
<CATALOG>
<CD>
<TITLE>Picture book</TITLE>
<ARTIST>Simply Red</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>Elektra</COMPANY>
<PRICE>7.20</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Red</TITLE>
<ARTIST>The Communards</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>London</COMPANY>
<PRICE>7.80</PRICE>
<YEAR>1987</YEAR>
</CD>
<TAPE>
<TITLE>Unchain my heart</TITLE>
<ARTIST>Joe Cocker</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>EMI</COMPANY>
<PRICE>8.20</PRICE>
<YEAR>1987</YEAR>
</TAPE>
<TAPE>
<TITLE>The dock of the bay</TITLE>
<ARTIST>Otis Redding</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Atlantic</COMPANY>
<PRICE>7.90</PRICE>
<YEAR>1987</YEAR>
</TAPE>
</CATALOG>
In the above example I would like to extract the data sets that are in the CD category first and the TAPE category second. How do I do this? I am able to parse the entire XML doc into an array that I can access using standard array syntax (i.e. xmlChildren[1]). But that gives me only one node or one specific title, how do I restrict to a specific type? Is there some way using the XML DOM to only reference a specific type?
Any suggestion or comment, or question would be greatly appreciated!