Created
February 1, 2012 20:56
-
-
Save kartikshah/1719270 to your computer and use it in GitHub Desktop.
Pass child element'd Node to unmarshal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JaxbUnmarshallerWithDocBuilder { | |
public static void main(String args[]){ | |
try{ | |
JAXBContext jc = JAXBContext.newInstance("com.kartikshah.api.account.wsdl"); | |
Unmarshaller u = jc.createUnmarshaller(); | |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | |
dbf.setNamespaceAware(true); | |
DocumentBuilder db = dbf.newDocumentBuilder(); | |
Document doc = db.parse(JaxbUnmarshallerWithDocBuilder.class.getResource("account.xml")); | |
Node fooSubtree = doc.getFirstChild(); | |
JAXBElement<Account> account = u.unmarshal( fooSubtree, Account.class); | |
} | |
catch (Exception e){ | |
// ... Omitted for brevity | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment