Listing D: appendChild example
Node ndProduct = XPathAPI.selectSingleNode(doc,"/catalog/products[@sku='123']"); Node ndNewColor = doc.createElement("color"); ndNewColor.appendChild(doc.createTextNode("red")); ndProduct.appendChild(ndNewColor);