Package com.fengjing.framework.jaxb.model

Examples of com.fengjing.framework.jaxb.model.Student


public class JaxbMarshaller {
 
  @Test
  public void student2xml() throws JAXBException{
    JAXBContext context=JAXBContext.newInstance(Student.class);
    Student student=new Student("admin", 18, "��������", new ClassRoom("classroom", "�������"));
    Marshaller marshaller = context.createMarshaller();
    //�O�ò�ݔ��<?xml version="1.0" encoding="UTF-8" standalone="yes"?>��Ϣ
    //marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
    marshaller.marshal(student, System.out);
  }
View Full Code Here


 
  @Test
  public void classroom2xml() throws JAXBException{
    JAXBContext context=JAXBContext.newInstance(Student.class);
    ClassRoom classRoom=new ClassRoom("classroom", "�������");
    Student student;
   
    List<Student> students=new ArrayList<Student>();
   
    for (int i = 1; i <= 10; i++) {
      student=new Student("admin", 18, "��������");
      students.add(student);
    }
    classRoom.setStudents(students);
   
    Marshaller marshaller = context.createMarshaller();
View Full Code Here

  public void xml2student() throws JAXBException{
    String str="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><student><age>18</age><classRoom classroomid=\"classroom\" classroomname=\"�������\"/><stuaddress>��������</stuaddress><stuname>admin</stuname></student>";
   
    JAXBContext context=JAXBContext.newInstance(Student.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    Student student = (Student) unmarshaller.unmarshal(new StringReader(str));
    System.out.println(student);
  }
View Full Code Here

TOP

Related Classes of com.fengjing.framework.jaxb.model.Student

Copyright © 2018 www.massapicom. 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.