Can I get an example that works on documents which are not DTD-specific but generic?

The xBeans project
includes many examples of Java code that works on documents of any DTD.
Such code requires you to essentially interpret the DOM representation of
the document and not depend on any particular elements, attributes or document
structure.