I have a CLOB column in my database which has an XML data. I retrieve that data and store it in a String variable(It is in XML format only). Now I need to PARSE that String using DOM parser. But before that, I need to do type conversion from String to XML. Is that possible? If I directly pass the String it gives me Exception and does not treat the String as XML.
NOTE: However if I write the string into a file and save it as a "file.xml" then it parses the xml file.
How to type convert String to XML? So that I can directly pass the string to the parser.
08-21-2005, 01:12 PM
Not knowing CLOB, database or XML this is a WAG.
Generally when creating an Object you need to look at the Constructor and see what different parameters it can take. Then see if the source object: String in this case fits or if the source object can be converted to an object type that the constructor takes.
For the class XML, look at its constructors. If none of them fit (ie take a String as a parameter) look at the XML class's methods to see if there are any of them that take a String.
Element sd = d.getRootElement();
Iterator iterator = l.iterator();
Element child = (Element) iterator.next();
and so on...
08-22-2005, 12:44 AM
I think the error is with the XML data that I am retrieving. It has some White space. This I noticed when I tried to write it into a file where it stopped after the first white space it encountered.
I think the Parser will accept the String provided if it is in the correct format (As told by Norm).
So can U please tell me how to remove the white space in between a string or can U tell me how to write a string into a file with ignoring the white spaces.
NOTE: I tried the parser.setIncludeIgnorableWhitespace(false); It didn't work and gives me same SAXException.