Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:51:15+00:00 2026-05-24T11:51:15+00:00

Is it possible to transform a POJO instance into its XML representation without storing

  • 0

Is it possible to transform a POJO instance into its XML representation without storing it to DB and load it back again in DOM4J mode (and from XML to POJO)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:51:15+00:00Added an answer on May 24, 2026 at 11:51 am

    I have not used this yet, but DOM4J appears to have some JAXB integration that could be used to convert your POJOs to XML (DOM4J):

    • http://dom4j.sourceforge.net/dom4j-1.6.1/apidocs/org/dom4j/jaxb/package-summary.html

    UPDATE

    DOM4J also offers a DocumentResult class that implements javax.xml.transform.Result. You can use JAXB to marshal to this class and then manipulate the resulting DOM4J Document object:

    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;
    
    import org.dom4j.Document;
    import org.dom4j.io.DocumentResult;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // Create the JAXBContext
            JAXBContext jc = JAXBContext.newInstance(Customer.class);
    
            // Create the POJO
            Customer customer = new Customer();
            customer.setName("Jane Doe");
    
            // Marshal the POJO to a DOM4J DocumentResult
            Marshaller marshaller = jc.createMarshaller();
            DocumentResult dr = new DocumentResult();
            marshaller.marshal(customer, dr);
    
            // Manipulate the resulting DOM4J Document object
            Document document = dr.getDocument();
            document.getRootElement().addAttribute("foo", "bar");
    
            // Output the result
            System.out.println(document.asXML());
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use XSLT to transform XML into something other than XML?
When using a browser to transform XML (Google Chrome or IE7) is it possible
Is it possible to perform a transform on multiple input XML files? It doesn't
I am using Javascript to load XML and transform it with XSLT. Everything works
I'm trying to transform one method call into another dynamically (at runtime). For instance,
I'm using XSLT to transform from one format of XML into another but I
I am using XSLT to transform a XML into a html/php file. In this
Is it possible to have transport security without authentication? I'm well aware of it's
Is it possible to transform the types of a parameter pack and pass it
I want to know if it is possible to transform a std::vector to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.