Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by vdyadechko ( 12 years ago )
package com.devexperts;
public class Main {
public static void main(String[] args) throws Exception {
final Customer customer = new Customer("ya", "gd");
JAXBContext c = JAXBContext c
Marshaller marshaller = context.createMarshaller();
StringWriter stringWriter = new StringWriter();
marshaller.marshal(customer, stringWriter);
Unmarshaller unmarshaller = context.createUnmarshaller();
Customer whatRead = (Customer)unmarshaller.unmarshal(new StringReader(stringWriter.toString()));
System.out.println(whatRead.getAddress() + " " + whatRead.getName());
}
@XmlRootElement(name="customer")
@XmlAccessorType(XmlAccessType.NONE)
public static final class Customer {
@XmlAttribute
private final String name;
@XmlElement
private final String address;
@SuppressWarnings("unused")
private Customer() {
this(null, null);
}
public Customer(String name, String address) {
this.name = name;
this.address = address;
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
}
}
Revise this Paste
Parent: 76043
Children: 76045