|
求大神 在java中传入一个XML样式的String类型,现在要取节点中的属性值 ,并且根节点中的类会随着不同格式发生变化。 类似这样: |
|
![]() |
急啊 就知道用dom4j解析 但没学过 啊 不知道怎么弄
|
![]() 10分 |
|
![]() 20分 |
正则
String s="<id>3</id>" ;
s+="<name>CLR</name>" ;
s+="<type>CLR</type>" ;
s+="<format>SITA</format>" ;
s+="<flightNo>9C8846</flightNo>" ;
Matcher m = Pattern.compile("<type>(.*?)</type>.*?<format>(.*?)</format>").matcher(s);
while(m.find()){
System.out.println(m.group(1)+"****"+m.group(2));
}
|
![]() 10分 |
|

