package beans;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class PrintConvertToBean {
/**
* print input message
* @param message
*/
public static void helloExample(Document message) {
if (message == null) {
System.out.println("There's no message here!");
return;
}
Element rootElement = message.getDocumentElement();
if (rootElement == null) {
System.out.println("There's no root element here!");
return;
}
System.out.println("The root element name is:"
+ rootElement.getNodeName());
System.out.println("The book categories are:");
NodeList types = rootElement.getElementsByTagName("category");
for(int i = 0;i<types.getLength();i++){
Element child = (Element) types.item(i);
System.out.println(child.getFirstChild().getNodeValue());
}
}
}