TopLink Wiki

Main
About
Javadoc
Forum
Resources

RecentChanges
About Wiki
Find Pages
Page Index

Set your name in
UserPreferences

Edit this page


Referenced by
Main




JSPWiki v2.0.52


TopLinkXML


Introduction to TopLink Object-XML Mapping by Blaise Doughan.

Simple example of writing an object to XML. forum:288692

import javax.xml.bind.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
...
Vector objects = session.readAllObjects;
 
JAXBContext jaxbContext = JAXBContext.newInstance("your_context_path");
Marshaller marshaller = jaxbContext.createMarshaller();
 
// Create an XML document to contain the fragments
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = builder.newDocument();
Element root = document.createElement("root");
document.appendChild(rootElement);
 
// Marshal each of the objects to the owning document
for (Iterator i = objects.iterator(); i.hasNext(); ) {
     marshaller.marshal(i.next(), root);	
}



Edit this page   More info...   Attach file...
This page last changed on 15-Feb-2005 12:54:10 PST by RenaudWaldura.