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

  • Home
  • SEARCH
  • 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 6787483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:22:18+00:00 2026-05-26T17:22:18+00:00

Suppose i have a xml file which has several nodes & children. I am

  • 0

Suppose i have a xml file which has several nodes & children. I am using jaxb (unmarshalling & marshalling) to update the xml file when requires but wanted to know what exactly happens when….. ??

<parent>
    <node>abc</node>
</parent>

now i wanted to update this xml by adding <node>xyz</node>, so what i do

  1. Unmaeshall this xml file to java Object and add this new node as java object.

  2. Marshall the updated Object to XML file.

my Question is : what happens when we marshall the java object to xml file ?

option a) xml file remove everything and write afresh.

option b) xml file only updated by just adding the new line.

  • 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-26T17:22:18+00:00Added an answer on May 26, 2026 at 5:22 pm

    If you are strictly talking about File objects then the answer given by Bozho is correct. If you consider the DOM representation then JAXB offers both approaches:

    Unmarshaller/Marshaller

    In the following code originalDOM != marshalledDOM.

    Node originalDOM;  // Populate original document
    
    JAXBContext jc = JAXBContext.newInstance(Customer.class);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    Customer customer = (Customer) unmarshaller.unmarshal(orginalDocument);
    
    Marshaller marshaller = jc.createMarshaller();
    marshalledDOM = marshaller.getNode(customer);
    

    Binder

    When using a Binder a link is maintained between the objects and the DOM nodes they were unmarshalled from. If you modify the unmarshalled object the Binder alows you to apply those changes back to the original DOM. This approach is very useful when there is unmapped content in the document that you need to keep (such as comments and processing instructions).

        JAXBContext jc = JAXBContext.newInstance(Customer.class);
    
        Binder<Node> binder = jc.createBinder();
        Customer customer = (Customer) binder.unmarshal(document);
        customer.getAddress().setStreet("2 NEW STREET");
        binder.updateXML(customer);
    

    For More Information

    • http://blog.bdoughan.com/2010/09/jaxb-xml-infoset-preservation.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i want to open an xml file which i have in my email
Suppose I have two XML files. First XML File: <?xml version=1.0?> <AccessRequest xml:lang=en-US> <AccessLicenseNumber>Your_License</AccessLicenseNumber>
I have a file, which is in XML format (consists just of root start
In a maven project I have several modules which only have a persitence.xml for
Suppose i have an xml document like this XML File: <document> <educationalsection> educational details
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
Suppose I have this XML as a string: <calles> <calle> <nombre>CALLAO AV.</nombre> <altura>1500</altura> <longitud>-58.3918617027</longitud>
I have an MSSQL2005 stored procedure here, which is supposed to take an XML
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I've a SmartGWT application which interacts with a mysql database using rpc services. Suppose

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.