java 写xml的问题

<?xml version="1.0" encoding="UTF-8"?>
姓名,与户主关系,身份证号码,职业,联系电话,备注


张3子
2
210225862220045

13840942711
hao//就是在这加上
张3女
2
210225862220041

13840942712
hao



这个是我生成的一段xml,可是我不想要这样的。我要下面这样的






下面是程序
doc = db.newDocument();

root = doc.createElement("root");

        tag= doc.createElement("tageName");
        info_root=doc.createElement("info_root");
        info=doc.createElement("info");
        doc.appendChild(root);

        tag.appendChild(doc.createTextNode(tagName));
        root.appendChild(tag);
        for(int i=0;i<list.size();i++){

            for(int j=0;j<fields.length;j++){  
               jkrs = doc.createElement(fields[j].toString());
               info.appendChild(jkrs);
               jkrs.appendChild(doc.createTextNode(list.get(i).get(fields[j])));


               }   
            root.appendChild(info_root);
            info_root.appendChild(info); 
            }

帮忙看看哪个节点加的不对!
我不想用dom4j。用的是
import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

[quote] info=doc.createElement("info"); [/quote]
应该放到外层循环里面。

[quote]doc = db.newDocument();

root = doc.createElement("root");

        tag= doc.createElement("tageName"); 
        info_root=doc.createElement("info_root"); 
        info=doc.createElement("info"); 
        doc.appendChild(root); 

        tag.appendChild(doc.createTextNode(tagName)); 
        root.appendChild(tag); 
        for(int i=0;i<list.size();i++){ 

            for(int j=0;j<fields.length;j++){  
               jkrs = doc.createElement(fields[j].toString()); 
               info.appendChild(jkrs); 
               jkrs.appendChild(doc.createTextNode(list.get(i).get(fields[j]))); 


               }   
            root.appendChild(info_root); 
            info_root.appendChild(info); 
            } [/quote]

程序写得够乱的哟!