This program return null for existing key-value.
Code:
File file = new File("document.xml");
JAXBContext context = JAXBContext.newInstance(Document.class);
Unmarshaller unmarshaller=context.createUnmarshaller();
Document document=(Document)unmarshaller.unmarshal(file);
Map<String, String> map=document.getValues();
System.out.println("Values="+map);
System.out.println(map.get("100300IDG"));
Output:-
Values={240400MAHAR=100010101, 100300IDG=44444444, 200200MDM=11221321, 341095TRAVERS=7070070, 340203BRUCKNER=545454, 490423SALEM=64845674, 100490MSC=2222222, 240371PRODUCTION=7777777, 250341FASTENAL=121212}
null
Code for document class.
@XmlRootElement
public class Document {
private Map<String, String> values = new HashMap<String, String>();
//Getter and setter for values
}
Document file that contain values and these values are populated into document object.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<document>
<values>
<entry>
<key>240400MAHAR</key>
<value>100010101</value>
</entry>
<entry>
<key>100300IDG</key>
<value>44444444</value>
</entry>
<entry>
<key>200200MDM</key>
<value>11221321</value>
</entry>
</values>
</document>