XML的问题 尤专门的xml文件操作的类,你直接查问党就可以哦了阿 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵,在baidu一搜一大堆啊哥们 好多,比如jdom 就挺方便的 用了Apache提供的jdom类包import org.jdom.input.*;import org.jdom.*;import java.util.*;import java.io.*;public class XMLExample2{ public static void main(String[] args) { SAXBuilder sb = new SAXBuilder(); try { Document doc = sb.build(new FileInputStream("text1.xml")); Element root = doc.getRootElement(); System.out.println("节点名:"+root.getName()); List lProperty = root.getAttributes(); Iterator it = lProperty.iterator(); while(it.hasNext()) { System.err.println(" : "+root.getAttribute(((Attribute)it.next()).getName()).getValue()); } List ro = root.getChildren(); Iterator it1 = ro.iterator(); while(it1.hasNext()) { Element el = (Element)it1.next(); lProperty = el.getAttributes(); Iterator it2 = lProperty.iterator(); while(it2.hasNext()) { System.err.println(" : "+el.getAttribute(((Attribute)it2.next()).getName()).getValue()); } } }catch(Exception e) { e.printStackTrace(); } } } <?xml version="1.0" encoding="GBK"?><VInfo ID='abc' Name='other'> <I User="KK" N="oo"/> <I User="KK" N="oo"/></VInfo> JSF在进入页面之前如何让他先调用我的一个bean里面的方法 网站支持多语言? Java可以执行一个EXCEL文件里面的宏吗? 数据交换中心问题 hibnertate 的映射关联怎么自动生成的? socket最应该注意的有哪些???? 急!!!!! jms和jboss的问题 关于三层开发中,用户如输入错误抛出空指针问题 使用xpath的问题? 请教一个实现逻辑上的问题,请大家说说原理 一个关于NoClassDefFoundError的问题? 急问struts中treeview中显示问题,恳请struts中做过treeview的高手提醒!!
import org.jdom.input.*;
import org.jdom.*;
import java.util.*;
import java.io.*;
public class XMLExample2
{
public static void main(String[] args)
{ SAXBuilder sb = new SAXBuilder();
try {
Document doc = sb.build(new FileInputStream("text1.xml"));
Element root = doc.getRootElement();
System.out.println("节点名:"+root.getName());
List lProperty = root.getAttributes();
Iterator it = lProperty.iterator();
while(it.hasNext())
{
System.err.println(" : "+root.getAttribute(((Attribute)it.next()).getName()).getValue());
}
List ro = root.getChildren();
Iterator it1 = ro.iterator();
while(it1.hasNext())
{
Element el = (Element)it1.next();
lProperty = el.getAttributes();
Iterator it2 = lProperty.iterator();
while(it2.hasNext())
{
System.err.println(" : "+el.getAttribute(((Attribute)it2.next()).getName()).getValue());
}
}
}catch(Exception e)
{
e.printStackTrace();
}
}
}
<VInfo ID='abc' Name='other'>
<I User="KK" N="oo"/>
<I User="KK" N="oo"/>
</VInfo>