Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

578 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