xstream

xstream可实现Bean到XML,XML到Bean的自动解析

 

        Persons persons = getPersons();
        XStream xstream = new XStream();
        xstream.alias("address", Address.class);
        xstream.alias("addresses", Addresses.class);
        xstream.alias("person", Person.class);
        xstream.alias("persons", Persons.class);
        String xml = xstream.toXML(persons);
        System.out.println(xml);

        Persons cre_person = (Persons) xstream.fromXML(xml);
        System.out.println(cre_person.toString());
 

你可能感兴趣的:(xstream)