日期:2014-05-18 浏览次数:20738 次
StringBuffer opdetail=new StringBuffer();
opdetail.append("<opDetail>");
opdetail.append("<recordInfo>");
opdetail.append("<fieldInfo><fieldChName>啊啊啊</fieldChName><fieldEnName>aaaaaa</fieldEnName><fieldContent>测试测试测试1111</fieldContent></fieldInfo>");
opdetail.append("<fieldInfo><fieldChName>啵啵啵</fieldChName><fieldEnName>bbbbbb</fieldEnName><fieldContent>测试测试测试2222</fieldContent></fieldInfo>");
opdetail.append("</recordInfo>");
opdetail.append("</opDetail>");
String aaa = opdetail.toString();
String bbb = "no";
String ccc = "";
Pattern p = Pattern.compile("<fieldEnName>([^</fieldEnName>]*)");
Matcher m = p.matcher(aaa);
Pattern p1 = Pattern.compile("<fieldContent>([^</fieldContent>]*)");
Matcher m1 = p1.matcher(aaa);
while (m.find()) {
ccc = m.group(1);
m1.find();
if(m.group(1).indexOf("aaaaaa")!=-1){
bbb = m1.group(1);
}
}
StringBuffer opdetail = new StringBuffer();
opdetail.append("<opDetail>");
opdetail.append("<recordInfo>");
opdetail.append("<fieldInfo><fieldChName>啊啊啊</fieldChName><fieldEnName>aaaaaa</fieldEnName><fieldContent>测试测试测试1111</fieldContent></fieldInfo>");
opdetail.append("<fieldInfo><fieldChName>啵啵啵</fieldChName><fieldEnName>bbbbbb</fieldEnName><fieldContent>测试测试测试2222</fieldContent></fieldInfo>");