求救 java转换成给树用的层级XML
id 名称 父id(0代表根节点)
1 11 0
2 22 1
3 33 2
4 44 1
5 55 3
6 66 2
7 77 5
如何用java 把以上数据转换成有层级的XML如
<item text="11" id="1" prentid="0">
<item text="22" id="2" prentid="1" >
<item text="66" id="6" prentid="2">
</item>
<item text="33" id="3" prentid="2">
<item text="55" id="5" prentid="3">
<item text="77" id="7" prentid="5">
</item>
</item>
</item>
</item>
<item text="44" id="4" prentid="1">
</item>
</item>