I need to put the values inside a pat as the values of my XML file for Ex:
Map<String, String> props = new HashMap<>(); props.put("role", "Admin"); props.put("externalId", "2ew1Q"); props.put("Property", "internal"); props.put("Execution", "internal"); My expected output should be:
<role>Admin</role> <externalId>2ew1Q</externalId> <Property>internal</Property> <Execution>internal</Execution> But instead of it, I'm getting
<entry string="role">Admin</entry> <entry string="Execution">internal</entry> <entry string="externalId">2ew1Q</entry> <entry string="Property">internal</entry> I have to do it with Simple XML, and this is my code:
@Root public class Data { @ElementMap(entry = "property", key = "key", attribute = true, inline = true) private Map<String, String> customProps; public Map<String, String> getData() { return customProps; } public void setData(Map<String, String> data) { this.customProps = data; } } public static void main(String[] args) throws Exception { Map<String, String> props = new HashMap<>(); props.put("role", "Admin"); props.put("externalId", "2ew1Q"); props.put("Property", "internal"); props.put("Execution", "internal"); Data customProps = new Data(); customProps.setData(props); Serializer serializer = new Persister(); File result = new File("example.xml"); serializer.write(customProps, result); }