custom converter in XStream
- by Raja Chandra Rangineni
Hi All,
I am using XStream to serialize my Objects to XML format. The formatted xml that I get is as below: node1, node2, node 3 are attributes of pojo,DetailDollars
DetailDollars
node1
100
/node1
node2
25
/node2
node3
10
/node3
/DetailDollars
I have requirement where in I have to calucluate a percentage, for example 100/ 25 and add the new node to the existing ones. So, the final output should be :
DetailDollars
node1 100 /node1
node2 25 /node2
node3 10 /node3
node4 4 /node4
DetailDollars
I wrote a custom converter and registered to my xstream object.
public void marshal(..){
writer.startNode("node4");
writer.setValue(getNode1()/ getnode2() );
writer.endNode();
}
But, the xml stream I get has only the new node:
DetailDollars
node4
4
/node4
/DetailDollars
I am not sure which xstream api would get me the desired format. could you please help me with this .
Thanks,
Raja chandra Rangineni.