public class Value_config {
Panel_config panelConfig;
Client_config clientConfig;
public Panel_config getPanelConfig() {
return panelConfig;
}
public void setPanelConfig(Panel_config panelConfig) {
this.panelConfig = panelConfig;
}
public Client_config getClientConfig() {
return clientConfig;
}
public void setClientConfig(Client_config clientConfig) {
this.clientConfig = clientConfig;
}
}
public class Panel_config {
String title;
int column;
int width;
int height;
int button;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getColumn() {
return column;
}
public void setColumn(int column) {
this.column = column;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getButton() {
return button;
}
public void setButton(int button) {
this.button = button;
}
}
public class Client_config {
int clientNum;
ClientVideo clientVideo;
public int getClientNum() {
return clientNum;
}
public void setClientNum(int clientNum) {
this.clientNum = clientNum;
}
public ClientVideo getClientVideo() {
return clientVideo;
}
public void setClientVideo(ClientVideo clientVideo) {
this.clientVideo = clientVideo;
}
}
public class ClientVideo {
List list;
public List<Client> getList() {
return list;
}
public void setList(List<Client> list) {
this.list = list;
}
}
public class Client {
String clientName;
String clientNo;
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getClientNo() {
return clientNo;
}
public void setClientNo(String clientNo) {
this.clientNo = clientNo;
}
}
public class ParserXml {
public static List parser(){
List list = new ArrayList();
try {
Document doc = new SAXBuilder().build("c:\a.xml");
Element rootEle = doc.getRootElement();
List listurl = XPath.selectNodes(rootEle, "//value-config/panel-config");
Value_config value_config = new Value_config();
if (null != listurl) {
for (Iterator iter = listurl.iterator(); iter.hasNext();) {
Panel_config obj = new Panel_config();
Element objElement = (Element) iter.next();
obj.setTitle(objElement.getChildTextTrim("title"));
//.....................
value_config.setPanelConfig(obj);
}
}
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
}
public class Test {
public static void main(String[] args) {
List list = ParserXml.parser();
}
}
基本上代码都有了,剩下的你完善完善就好了。用jdom解析xml,供参考。