*/
public Item getItemContent(Document doc)
{
Music music = new Music();
CustomerReview review = null;
Offer offer = null;
NodeList nodes, kids1, kids2, kids3 = null;
Node node, kid1, kid2, kid3 = null;
int i, j, k, x = 0;
nodes = doc.getElementsByTagName("ASIN");
for(i = 0; i < nodes.getLength(); i++)
{
if(nodes.item(i).getParentNode().getNodeName().equals("Item"))
{
music.setAsin(nodes.item(i).getTextContent());
}
}
nodes = doc.getElementsByTagName("DetailPageURL");
if(nodes.getLength() > 0)
{
music.setUrl(nodes.item(0).getTextContent());
}
nodes = doc.getElementsByTagName("SalesRank");
if(nodes.getLength() > 0)
{
music.setSalesRank(nodes.item(0).getTextContent());
}
nodes = doc.getElementsByTagName("URL");
for(i = 0; i < nodes.getLength(); i++)
{
if(nodes.item(i).getParentNode().getNodeName().equals("LargeImage"))
{
music.setImage(nodes.item(i).getTextContent());
}
}
nodes = doc.getElementsByTagName("ItemAttributes");
if(nodes.getLength() > 0)
{
node = nodes.item(0);
kids1 = node.getChildNodes();
for(i = 0; i < kids1.getLength(); i++)
{
kid1 = kids1.item(i);
if(kid1.getNodeName().equals("Author"))
{
music.addArtist(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Creator"))
{
music.addArtist(kid1.getTextContent());
}
if(kid1.getNodeName().equals("EAN"))
{
music.setEan(kid1.getTextContent());
}
if(kid1.getNodeName().equals("ListPrice"))
{
kids2 = kid1.getChildNodes();
for(j = 0; j < kids2.getLength(); j++)
{
kid2 = kids2.item(j);
if(kid2.getNodeName().equals("FormattedPrice"))
{
music.setPrice(kid2.getTextContent());
}
}
}
if(kid1.getNodeName().equals("ReleaseDate"))
{
music.setPublicationDate(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Publisher"))
{
music.setPublisher(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Studio"))
{
music.setStudio(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Title"))
{
music.setTitle(kid1.getTextContent());
}
}
}
nodes = doc.getElementsByTagName("EditorialReview");
if(nodes.getLength() > 0)
{
node = nodes.item(0);
kids1 = node.getChildNodes();
for(i = 0; i < kids1.getLength(); i++)
{
kid1 = kids1.item(i);
if(kid1.getNodeName().equals("Content"))
{
music.setSummary(kid1.getTextContent());
}
}
}
nodes = doc.getElementsByTagName("AverageRating");
if(nodes.getLength() > 0)
{
music.setAverageRating(nodes.item(0).getTextContent());
}
nodes = doc.getElementsByTagName("Review");
for(i = 0; i < nodes.getLength(); i++)
{
review = new CustomerReview();
node = nodes.item(i);
kids1 = node.getChildNodes();
for(j = 0; j < kids1.getLength(); j++)
{
kid1 = kids1.item(j);
if(kid1.getNodeName().equals("ASIN"))
{
review.setAsin(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Rating"))
{
review.setRating(kid1.getTextContent());
}
if(kid1.getNodeName().equals("HelpfulVotes"))
{
review.setReviewVotes(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Reviewer"))
{
kids2 = kid1.getChildNodes();
for(k = 0; k < kids2.getLength(); k++)
{
kid2 = kids2.item(k);
if(kid2.getNodeName().equals("CustomerId"))
{
review.setCustomerId(kid2.getTextContent());
}
if(kid2.getNodeName().equals("Name"))
{
review.setCustomerName(kid2.getTextContent());
}
if(kid2.getNodeName().equals("Nickname"))
{
review.setCustomerNick(kid2.getTextContent());
}
if(kid2.getNodeName().equals("Location"))
{
review.setCustomerLocation(kid2.getTextContent());
}
}
}
if(kid1.getNodeName().equals("Date"))
{
review.setDate(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Summary"))
{
review.setSummary(kid1.getTextContent());
}
if(kid1.getNodeName().equals("Content"))
{
review.setContent(kid1.getTextContent());
}
}
music.addReview(review);
}
nodes = doc.getElementsByTagName("Offer");
for(i = 0; i < nodes.getLength(); i++)
{
offer = new Offer();
node = nodes.item(i);
kids1 = node.getChildNodes();
for(j = 0; j < kids1.getLength(); j++)
{
kid1 = kids1.item(j);
if(kid1.getNodeName().equals("OfferAttributes"))
{
kids2 = kid1.getChildNodes();
for(k = 0; k < kids2.getLength(); k++)
{
kid2 = kids2.item(k);
if(kid2.getNodeName().equals("Condition"))
{
offer.setCondition(kid2.getTextContent());
}
}
}
if(kid1.getNodeName().equals("OfferListing"))
{
kids2 = kid1.getChildNodes();
for(k = 0; k < kids2.getLength(); k++)
{
kid2 = kids2.item(k);
if(kid2.getNodeName().equals("OfferListingId"))
{
offer.setId(kid2.getTextContent());
}
if(kid2.getNodeName().equals("Price"))
{
kids3 = kid2.getChildNodes();
for(x = 0; x < kids3.getLength(); x++)
{
kid3 = kids3.item(x);
if(kid3.getNodeName().equals("FormattedPrice"))
{
offer.setPrice(kid3.getTextContent());
}
}
}
}
}