Skip to content

Instantly share code, notes, and snippets.

@DinoChiesa
Created December 7, 2017 00:52
Show Gist options
  • Save DinoChiesa/04a168afe30600c0b6ea7ad41ba7b310 to your computer and use it in GitHub Desktop.
Save DinoChiesa/04a168afe30600c0b6ea7ad41ba7b310 to your computer and use it in GitHub Desktop.
Deserialize XML (Java fragment)
String canonicalPath = "/users/foo/bar/something.xml";
String xml = new String(Files.readAllBytes(Paths.get(canonicalPath)), StandardCharsets.UTF_8);
XMLStreamReader sr = XMLInputFactory.newFactory().createXMLStreamReader(new FileInputStream(cpath));
XmlMapper mapper = new XmlMapper();
Map m = (Map) mapper.readValue(sr, Object.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment