Wednesday, June 3, 2009


Time sink...

I spent way too much time trying to get this to work. It is upsetting me, so it goes on the blog.

The general idea is I wanted to change an XML file from my Java program. My approach was to load it into a Document object, manipulate it. Then when I was done I would use a DOMSource and a Transformer to convert this Document to a String.

What was supposed to work that did NOT was giving DOMSource a non-document an element. I wanted a string for a particular element. DOMSource would give me an empty string when I gave it a viable element, but gave me exactly what I expected when I gave it a real document.

I have no doubt that there is some magic I did not adhere to that will get this to work; by God I am have a limited life span!! Someday I will be savvy enough to deal with this problem I guess...but for now I found it easier to convert the whole document to a string and use regex to extract the node I wanted. Man!!

No comments: