1 year ago

#332747

test-img

GoranM

Jackson XML Mapper: how to serialize Java object to org.w3c.dom.Document or javax.xml.transform.dom.DOMResult

It is very easy to serialize Java object to a string using something like:

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
...    
public void serialize() throws Exception {
  MyPojo object = new MyPojo();
  String xml = new XmlMapper().writeValueAsString(object);
}

But I have difficulties understanding how to get org.w3c.dom.Document or javax.xml.transform.dom.DOMResult as a result of this serialization (because I'll be doing XSLT transformation immediately after so I'd like to avoid unnecessary string conversions)?

java

xml

jackson

jackson-dataformat-xml

0 Answers

Your Answer

Accepted video resources