tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 iBATIS > Basics > XML Result

XML Result 

The following example shows using XML result class. It provides a way of serializing results to an XML string. The attribute xmlResultName="STUDENT" allows us to specify the ROOT XML Tag name.

File Name  :  
/IBATIS001/config/basic/XMLResultName.xml 

File Name  :  
com/bethecoder/tutorials/ibatis/tests/basic/XMLResultName.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.ibatis.tests.basic;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class XMLResultName {

  /**
   @param args
   @throws IOException 
   @throws SQLException 
   */
  public static void main(String[] argsthrows IOException, SQLException {

    Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
    SqlMapClient sqlMapClent = SqlMapClientBuilder.buildSqlMapClient(reader);

    String studentXML = (StringsqlMapClent.queryForObject("Student.getXMLById"1);
    System.out.println(studentXML);
    
  }
}
   

It gives the following output,

File Name  :  
/IBATIS001/src/com/bethecoder/tutorials/ibatis/tests/basic/XMLResult.xml 



 
  


  
bl  br