大家好,我有这样的xml文件:
<data>
<pattern>^[sS].*</pattern>
<destination>C:\\Server\\s\\</destination>
</data>
<data>
<pattern>^[dD].*</pattern>
<destination>C:\\Server\\d\\</destination>
</data>
我使xml成为这样的对象:
XStream xstream = new XStream(new StaxDriver());
// Datas datas = new Datas();
File xmlx = new File("E:\\FileConfig.xml");
xstream.alias("datas", Datas.class);
xstream.alias("data", DataRegex.class);
xstream.processAnnotations(DataRegex.class);
xstream.processAnnotations(Datas.class);
Datas dataz = (Datas) xstream.fromXML(xmlx);
我有类数据和DataRegex:
@XStreamAlias("data")
public class DataRegex {
public String getPattern() {
return pattern;
}
public void setName(String pattern) {
this.pattern = pattern;
}
public String getDes() {
return destination;
}
public void setDes(String destination) {
this.destination = destination;
}
@XStreamAlias("destination")
private String destination;
@XStreamAlias("pattern")
private String pattern;
}
接下来,我想从数组元素(例如'pattern'值)中获取一个元素,以便与if-else条件下的任何数据进行比较。有人可以帮助我吗?