XPath, JAXP and the Default Namespace

So you’ve just finished parsing a document with your validating namespace aware document factory and you’ve gone to select some nodes using XPath and nothing has appeared (no nodes where selected). You’ve tried changing the XPath expression, making it simpler and simpler and still nothing. Chances are it’s not he XPath that’s at fault it’s your XML.Continue reading

Validating SAX Parser


I’ve been working with the built in Java XML libraries quite a bit lately and one of the things I’ve noticed is that there are very few good snippets of what I call recipe code – little bits of code that show you how to complete a specific task. In this article I show you how to use JAXP 1.3/1.4 to load a schema from the classpath and create a validating SAX parser.Continue reading

Which Java XML Library Should You Use

In the past I have always used either JDOM or Dom4J to interact with XML but I’ve never really been overly happy with either library. JDOM is very simple to use and great for simple XML structures but as soon as you want to do something a little more complex it becomes hard work. Dom4J is more powerful but I find the API to be, shall we just say, strange. I’ve never really found any problems with either project I just thought it was time to question why I was using them.Continue reading

Pretty Printing XML with JAXP

Java has a wide selection of built in XML handling capabilities but they are little used by most developers because they are felt, unfairly I think, to be difficult to use. I freely admit that I fell into that camp until fairly recently when I became a convert. Over the next few days I hope to writing some short articles giving hints and tips on using JAXP and the build in Java XML tools. First up is pretty printing.Continue reading