Howdy Partners Need some help... I was able to print out the XML nodes in the command prompt for debugging like so: Document customers <customers> <customer id="0001"> <name >Ariel S. Valentin</name> <userid>Ariel_V</userid> </customer> .... </customers> Number of Customers=3 Elements Customer Node List 3 Press any key to continue... Now in order to validate to XML schemas I had to add the "endorsed" folder to the JRE, sadly I am getting a "null" instead of the nodes (elements call them what you will). Shouldn't it at least give me the Hash address? Document customers Entire List [customers: null] Number of Customers=3 Elements Customer Node List 3 Press any key to continue... I want the best of both worlds, where it could be easy to debug by seeing what the actual nodes are and use XSD validation. What can I do? Any Ideas? Anyone else face this problem? Here is a Code Snippit: //Please excuse the inconsistency and poor style document = builder.parse("c:/xmlcache/customer.xml"); System.out.print("Document " + document.getFirstChild().getNodeName() +"\n"); Element entireList = (Element) document.getFirstChild(); System.out.print("Entire List "+ entireList +"\n"); NodeList customerNL = document.getElementsByTagName("customer");
System.out.print("Number of Customers=" + customerNL.getLength() + "\n");
StringBuffer sb = new StringBuffer("Elements\n"); sb.append("Customer Node List " + customerNL.getLength()+"\n"); System.out.print(sb.toString());
A. Valentin
William Brogden
Author and all-around good cowpoke
Rancher
Bill, Thanks for replying. I went back and read the Node interfaces API and now realize I get exactly what I should for an empty or complex element "null", not a string representation of the node and all it's children. I guess the difference is what Crimson returns as oppossed to Xerces. This is what I got using crimson parser Advantage for me!- Easy to debug Disadvantage-Unable to validate schemas with this: The Document Itself rg.apache.crimson.tree.XmlDocument@1034bb5 Document #document docElement=<customers> <customer id="0001"> <name>Ariel S. Valentin</name> <userid>Ariel_V</userid> .... </customers> docElements Tag Name=customers Customer Node List=org.apache.crimson.tree.ParentNode$TagList@186d4c1 First Customer element=<customer id="0001"> <name>Ariel S. Valentin</name> <userid>Ariel_V</userid> </customer> Press any key to continue... After adding xerces: UGG! Seeing null makes me uncomfortable... The Document Itself:[#document: null] Document #document docElement=[customers: null] docElements Tag Name=customers Customer Node List=org.apache.xerces.dom.DeepNodeListImpl@1ded0fd First Customer element=[customer: null] Press any key to continue... Code Snippit: document = builder.parse("c:/xmlcache/customer.xml"); System.out.print("The Document Itself:"+ document +"\n"); System.out.print("Document "+ document.getNodeName() +"\n"); Element docElement; NodeList customerNL;