Provides Product Info. for requested XML document.
// Extract sku attribute
String sku = request.getAttribute("sku");
ProductBean product = (ProductBean) products.get(sku);
// Create XML Document to store Product data
DocumentBuilder docBuilder = XMLParserUtils.getXMLDocBuilder();
Document doc = docBuilder.newDocument();
// Create Product Name Element
Text productNameText = doc.createTextNode(product.getName());
Element nameNode = doc.createElement("name");
nameNode.appendChild(productNameText);
// Create Product Description Element
Text productDescriptionText =
doc.createTextNode(product.getDescription());
Element descriptionNode = doc.createElement("description");
descriptionNode.appendChild(productDescriptionText);
// Create Product Name Element
Text productPriceText = doc.createTextNode(
Double.toString(product.getPrice()));
Element priceNode = doc.createElement("price");
priceNode.appendChild(productPriceText);
// Create Root Product Element
Element productNode = doc.createElement("product");
productNode.setAttribute("sku", sku);
productNode.appendChild(nameNode);
productNode.appendChild(descriptionNode);
productNode.appendChild(priceNode);
return productNode;