String to XML


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: String to XML

  1. #1
    Join Date
    Jan 2005
    Location
    INDIA
    Posts
    42

    Question String to XML

    Hi All,
    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,
    Bala

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    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.

  3. #3
    Join Date
    Aug 2005
    Posts
    4
    dunno if its what u wnt but why dont u try this -

    Code:
    StringReader sr=new StringReader("<XML DATA>")
    BufferedReader br=new BufferedReader(sr);
    SAXBuilder builder=new SAXBuilder();
    Document d=builder.build(br);
    u can manipulate the elements using

    Code:
    Element sd = d.getRootElement();
    List l=sd.getChildren();
                    Iterator iterator = l.iterator();
                    while (iterator.hasNext())
                    {
                        Element child = (Element) iterator.next();
                        List l2=child.getChildren();
    ...............
    and so on...

  4. #4
    Join Date
    Jan 2005
    Location
    INDIA
    Posts
    42

    Question

    Hi,
    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.

    Please Help.
    Thanks & Regards,
    Bala

Similar Threads

  1. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 02:32 PM
  2. Replies: 1
    Last Post: 06-05-2001, 06:12 AM
  3. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 0
    Last Post: 08-10-2000, 09:16 PM
  4. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 07:36 AM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center