Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/MOXy/Dynamic/XmlToDynamicEntity"

< EclipseLink‎ | Examples‎ | MOXy‎ | Dynamic
(Unmarshal DynamicEntities from XML)
(Unmarshal DynamicEntities from XML)
Line 8: Line 8:
 
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 
DynamicEntity customer = (DynamicEntity) unmarshaller.unmarshal(xmlInputStream);
 
DynamicEntity customer = (DynamicEntity) unmarshaller.unmarshal(xmlInputStream);
 +
</source>
 +
 +
==XML Document==
 +
Below is a sample XML document for this example.
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<customer xmlns="www.example.org">
 +
  <name>Jane Doe</name>
 +
  <address>
 +
      <street>1 Any Street</street>
 +
      <city>Any Town</city>
 +
  </address>
 +
</customer>
 
</source>
 
</source>

Revision as of 12:15, 24 June 2010

Overview

In this example you will learn how to unmarshal dynamic entities from XML.

Unmarshal DynamicEntities from XML

The Unmarshaller obtained from the DynamicJAXBContext is a standard unmarshaller, and can be used normally to unmarshal instances of DynamicEntity.

FileInputStream xmlInputStream = new FileInputStream("src/example/dynamic/customer.xml");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
DynamicEntity customer = (DynamicEntity) unmarshaller.unmarshal(xmlInputStream);

XML Document

Below is a sample XML document for this example.

<?xml version="1.0" encoding="UTF-8"?>
<customer xmlns="www.example.org">
   <name>Jane Doe</name>
   <address>
      <street>1 Any Street</street>
      <city>Any Town</city>
   </address>
</customer>

Back to the top