I have a huge problem with parsing an XML file to a different format. I'm trying to get all the related data like stated in this link: http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/ (I searched stackoverflow before and found this link)
I use the interface XMLReader to parse and the XML Serializer for the output.
I just need to convert my XML with a DTD to another XML with a different DTD. The difference is that, instead of elements from my source XML, most of the children are now attributes in the target XML. There are no new elements, only a different arrangement.
Has anyone an idea how to deal with the problem with a SAX parser?
You can use XMLFilters for that. See Elliotte Rusty Harold's book for explanation and examples:
BTW the mkyong tutorial glosses over how the characters method works, that tends to bite a lot of people when they find their element data getting truncated. There's a better tutorial on Oracle's site.