String to XML
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.
Thanks & Regards,
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.
dunno if its what u wnt but why dont u try this -
u can manipulate the elements using
StringReader sr=new StringReader("<XML DATA>")
BufferedReader br=new BufferedReader(sr);
SAXBuilder builder=new SAXBuilder();
and so on...
Element sd = d.getRootElement();
Iterator iterator = l.iterator();
Element child = (Element) iterator.next();
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.
Thanks & Regards,
By mdengler in forum ASP.NET
Last Post: 11-26-2002, 03:32 PM
By Fred Mayes in forum Java
Last Post: 06-05-2001, 07:12 AM
By Julian Milano in forum VB Classic
Last Post: 08-10-2000, 10:16 PM
By chandra in forum VB Classic
Last Post: 06-22-2000, 08:36 AM
By Robert Rieth in forum VB Classic
Last Post: 04-11-2000, 04:21 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL