对了,结点信息类似如下
<?xml version="1.0" encoding="gb2312"?>
<lists>
<list>
<id>1</id>
<username>冯奎</username>
<time>01-4-23 18:26:56</time>
<homepage>http://www.getjob.com.cn</homepage>
<email>[email protected]</email>
<context>我的留言</context>
</list>
<list>
<id>2</id>
<username>妞妞</username>
<time>01-6-23 18:26:56</time>
<homepage>http://www.neworiental.org</homepage>
<email>[email protected]</email>
<context>测试留言</context>
</list>
</lists>
<?xml version="1.0" encoding="gb2312"?>
<lists>
<list>
<id>1</id>
<username>冯奎</username>
<time>01-4-23 18:26:56</time>
<homepage>http://www.getjob.com.cn</homepage>
<email>[email protected]</email>
<context>我的留言</context>
</list>
<list>
<id>2</id>
<username>妞妞</username>
<time>01-6-23 18:26:56</time>
<homepage>http://www.neworiental.org</homepage>
<email>[email protected]</email>
<context>测试留言</context>
</list>
</lists>
郁闷的不行了,希望高手能给与指点
QQ21359875
我如果搞出来就到你这里来回贴!
对于这种菜单,在写程序的过程中是经常遇到的.解决的方法各有不同.可以从网上找一些例子来照着写.
http://www.java-cn.com/technology/technology_detail.jsp?id=2913
<car vin="123fhg5869705iop90">
<!--Description of a car-->
<make>Toyota</make>
<model>Celica</model>
<year>1997</year>
<color>green</color>
<license state="CA">1ABC234</license>
</car> ???浜??访矗?let us go! 第一步,??建根元素 Element carElement = new Element("car");
Document myDocument = new Document(carElement); 因??一?? XML 文?n必??一直有一??唯一的根元素,所以 Document ?? Element 放在它的??造器中。 第二步,添加一?? Attribute carElement.addAttribute(new Attribute("vin", "123fhg5869705iop90")); 第三步,添加其他元素 carElement.addContent(new Element("make").addContent("Toyota")); carElement.addContent(new Element("model").addContent("Celica"));
carElement.addContent(new Element("year").addContent("1997"));
carElement.addContent(new Element("color").addContent("green"));
carElement.addContent(new Element("license").addContent("1ABC234").addAttribute("state", "CA")); 第四步,添加一?l?]?? carElement.addContent(new Comment("Description of a car")); 第五步,?x一??子元素 Element yearElement = carElement.getChild("year"); 第六步,?h除子元素 boolean removed = carElement.removeChild("year"); 第七步,存?P FileWriter writer = new FileWriter("/some/directory/myFile.xml");
outputter.output(myDocument, writer);
writer.close();