Given the XML below, I need to parse it and output names of all books and the authorname if any of the authors are from the USA.
<?xml version="1.0" encoding="iso-8859-1"?>
<bookstore>
<categories>
<category>Cooking</category>
<category>Children</category>
<category>Fiction</category>
</categories>
<books>
<book>
<title>Everyday Italian</title>
<authors>
<author>
<name>Giada De Laurentiis</name>
<country>USA</country>
</author>
</authors>
<price>30.00</price>
</book>
<book>
<title>XQuery Kick Start</title>
<authors>
<author>
<name>James McGovern</name>
<country>Sweden</country>
</author>
<author>
<name>Per Bothner</name>
<country>USA</country>
</author>
</authors>
<price>49.99</price>
</book>
</books>
</bookstore>
How can I do this?
1 Answer