tags:

views:

13

answers:

1

I have used the scomp tool from XMLBeans to generate java classes and then populated the fields in an XmlObject (I wrote this code some time ago). I now need to convert this object into the Element class used by the XOM library.

Is there an easier way than by traversing the XmlObject using an XmlCursor and then adding child nodes to the target Element as you go? I had a look at possibly using some of the org.w3.dom.* classes but I'm having trouble finding something that will be easily translatable between the two libraries.

A: 

I think I've worked out a solution which I'll leave here in case anyone else has this problem.

public static Element translate(XmlObject o)
{
  org.w3c.Document docOld = (org.w3c.dom.Document) o.newDomNode();
  nu.xom.Document docNew = DOMConverter.convert(docOld);
  return docNew.getRootElement();
}
Catchwa