@Test public void xmlToObject() throws Exception { JibxSample.xmlToObject(); User u = JibxSample.xmlToObject(); }
public static User xmlToObject(){ try { IBindingFactory bfact = BindingDirectory.getFactory(User.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); File dataFile = new File("JibxSample.xml"); InputStream in = new FileInputStream(dataFile); User user = (User) uctx.unmarshalDocument(in, null); System.out.println("userName:" + user.getUserName()); for (LoginLog log : user.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return user; }catch (Exception e){ return null; } }
JibxSample { public static User xmlToObject(){ try { IBindingFactory bfact = BindingDirectory.getFactory(User.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); File dataFile = new File("JibxSample.xml"); InputStream in = new FileInputStream(dataFile); User user = (User) uctx.unmarshalDocument(in, null); System.out.println("userName:" + user.getUserName()); for (LoginLog log : user.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return user; }catch (Exception e){ return null; } } }
JibxSample { public static User xmlToObject(){ try { IBindingFactory bfact = BindingDirectory.getFactory(User.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); File dataFile = new File("JibxSample.xml"); InputStream in = new FileInputStream(dataFile); User user = (User) uctx.unmarshalDocument(in, null); System.out.println("userName:" + user.getUserName()); for (LoginLog log : user.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return user; }catch (Exception e){ return null; } }  }
JibxSample { public static User xmlToObject(){ try { IBindingFactory bfact = BindingDirectory.getFactory(User.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); File dataFile = new File("JibxSample.xml"); InputStream in = new FileInputStream(dataFile); User user = (User) uctx.unmarshalDocument(in, null); System.out.println("userName:" + user.getUserName()); for (LoginLog log : user.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return user; }catch (Exception e){ return null; } }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args); }
JibxSample { public static User xmlToObject(){ try { IBindingFactory bfact = BindingDirectory.getFactory(User.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); File dataFile = new File("JibxSample.xml"); InputStream in = new FileInputStream(dataFile); User user = (User) uctx.unmarshalDocument(in, null); System.out.println("userName:" + user.getUserName()); for (LoginLog log : user.getLogs()) { if (log != null) { System.out.println("访问IP: " + log.getIp()); System.out.println("访问时间: " + log.getLoginDate()); } } return user; }catch (Exception e){ return null; } }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args);  }