易截截图软件、单文件、免安装、纯绿色、仅160KB

xml 与 javaBean 互换

   在工作中经常遇到到另外一个服务器读取数据,其中一种最常用的方法,就是用xml进行数据传递,比如A服务器到B服务器得到对应的xml格式的数据,A得到之后进行解析。一般这种解析分为DOM解析和SAX解析。这里不是探讨DOM与SAX解析的区别和优点,只是介绍一个小框架,实现JAVABean和XML的转换,傻瓜式的转换。---------------------------XStream
    其官方网站是http://xstream.codehaus.org/
JAVAbEAN---->XML
咱们首先得一个对象,比如这个对象是Person
public class Persone {
private String firstName;
private String lastName;
private PhoneNumber phone;
private PhoneNumber fax;

public Persone(String firstName, String lastName) {
super();
this.firstName = firstName;
this.lastName = lastName;
}
public Persone() {
super();
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public PhoneNumber getPhone() {
return phone;
}
public void setPhone(PhoneNumber phone) {
this.phone = phone;
}
public PhoneNumber getFax() {
return fax;
}
public void setFax(PhoneNumber fax) {
this.fax = fax;
}


}
对象PhoneNumber
public class PhoneNumber {
private int code;
private String number;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public PhoneNumber(int code, String number) {
super();
this.code = code;
this.number = number;
}
public PhoneNumber() {
super();
}

}
  XStream xstream = new XStream(new DomDriver()); //初使化XStream
  xstream.alias("person", Persone.class);//对Persone.class名一个别名
  xstream.alias("phonenumber", PhoneNumb


相关文档:

php之XML转数组函数

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......

Delphi与XML文档

同步程序案例
procedure TGetOrderThread.PostDB(webnr:WideString);
var
  Err: String;
  SetWebnr:WideString;
  xmlDoc: IXMLDocument;
  root: IXMLNode;
  rowc: IXMLNode;//记录数
  rows: IXMLNodeList;//主记录列表
  row: IXMLNode;
  drows: IXMLNodeList;// ......

xml解析


在java应用开发中我们和xml打交道得机会太平凡了,一般情况下我看会用JDOM或是DOM4j来解析我们得XML文件,下面是一个Dom4j解析xml文件得例子,其中包括了对xml文件得取值、赋值、提取节点、节点得遍历等。
SAXReader reader =
new
SAXReader();   
Document doc = reader.read(...);  &nb ......

快逸报表导出成XML文件


快逸报表有着强大的输出功能,可以直接把web报表导出为Excel、Word、Pdf、Txt等文件形式。但是一些web报表用户希望可以将报表导出到XML文件中以便对数据进行分析与解析,这样就需要我们用一些特殊的方法去实现了。
实现思路
:导出XML功能的可以通过将计算好的IReport对象传递给快逸提供的com.runqian.report4.view.xml ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号