Package com.fengjing.framework.xstream.xml2bean

Source Code of com.fengjing.framework.xstream.xml2bean.DeserializingXM2Object

package com.fengjing.framework.xstream.xml2bean;

import com.fengjing.framework.xstream.Person;
import com.fengjing.framework.xstream.PhoneNumber;
import com.thoughtworks.xstream.XStream;

/**
* @see http://xstream.codehaus.org/tutorial.html
* @author scott
*
*/
public class DeserializingXM2Object {
 
  public static void main(String[] args) {
   
    XStream xstream = new XStream();
    //XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library
    //XStream xstream = new XStream(new StaxDriver()); // does not require XPP3 library starting with Java 6
   
    xstream.alias("person", Person.class);
    xstream.alias("phonenumber", PhoneNumber.class);
   
    String xml="<person><firstname>Joe</firstname><lastname>Walnes</lastname><phone><code>123</code><number>1234-456</number></phone><fax><code>123</code><number>9999-999</number></fax></person>";
   
    Person person = (Person)xstream.fromXML(xml);
   
    System.out.println(person);
  }
}
TOP

Related Classes of com.fengjing.framework.xstream.xml2bean.DeserializingXM2Object

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.