inserting XML Documents into databases

Posted on 2003-03-10
Medium Priority
Last Modified: 2010-03-31

I have an XML document which needs to be inserted into a database(in this particular case a Lotus DB).
The problem that I am having is that the column into which I want to insert this Document is a string..
so I somehow need to be able to convert the XML Doc into a string..

Does anyone have any snippets of code by which you can achieve this....i reckon I should be using a serializer in some sort of fashion..but I am unclear as to how to use it..

Any advice would be helpful..

Thanks for your time.
Question by:Prett
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

msterjev earned 520 total points
ID: 8101732
If you use Apache Xerces and Xalan you should use org.apache.xml.serialize.XMLSerializer! For example:

Document doc....
StringWriter sw=new StringWriter();
XMLSerializer serializer=new XMLSerializer(sw,null);
String xmlString=sw.getBuffer().toString();
//And write xmlString to the database;
LVL 35

Expert Comment

ID: 8101962
 It's not necessary to serialize it at all. Just call the toString() method (inherited from the Object class) on your XML object and it should be fine.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question