■ 참고 : [ajax] 기본 샘플 소스 xml 파싱해서 읽어서 뿌리기
■ jquery에서 서버로 xml데이터를 요청하는 예제, dataTye=’xml’로 요청을 한다.
<!DOCTYPE html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta charset="utf-8"> <head> <script src='/js/jquery/jquery-1.11.0.min.js'></script> <script> $(document).ready(function() { $("#log").append("xml download 테스트 시작<br/>"); $.ajax({ url : '/simplexml/content.xml', type : 'post', data : 'name=dummay&age=28', dataType : 'xml', success : function(xml) { // xml 문서 item 기준으로 분리후 반복 $(xml).find('item').each(function(){ var link = $(this).find("link").text(); var title = $(this).find("title").text(); var description = $(this).find("description").text(); var tag = $(this).find("tag").text(); var view_text = link + title + description + tag ; $("#log").append(view_text); // #id 에 view_text 삽입 }); }, error : function() { console.error('error'); } }); }); </script> </head> <body><div id="log"></div></body> </html>
■ spring controller 코드, produces=”application/xml;charset=utf-8″
@Controller @RequestMapping("simplexml") public class SimpleXMLController { @RequestMapping( value = "content.xml", method = RequestMethod.POST, produces="application/xml;charset=utf-8") @ResponseBody public String listSample(HttpServletRequest request) throws Exception { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("<item>"); stringBuffer.append(" <category>"); stringBuffer.append(" <![CDATA[ 카테고리 ]]>"); stringBuffer.append(" </category>"); stringBuffer.append(" <title>"); stringBuffer.append(" <![CDATA[ 제목 ]]>"); stringBuffer.append(" </title>"); stringBuffer.append(" <link>"); stringBuffer.append(" http://주소.."); stringBuffer.append(" </link>"); stringBuffer.append(" <description>"); stringBuffer.append(" <![CDATA[ 내용 ]]>"); stringBuffer.append(" </description>"); stringBuffer.append(" <tag>"); stringBuffer.append(" <![CDATA[ 태그 ]]>"); stringBuffer.append(" </tag>"); stringBuffer.append("</item>"); return stringBuffer.toString(); } }
- SpringBoot Port 변경 2022년 12월 27일
- jQuery checkbox 전체 선택/해제 예제 2022년 3월 15일
- Highcharts error #17 2019년 7월 10일
- Highchart TypeError: c.init is not a function 2019년 7월 10일
- Highchart 크기 조정 2019년 7월 8일
- Highcharts error #13 2019년 7월 8일
- Spring 트랜잭션 관리 2019년 6월 20일
- Spring RESTful 웹 서비스 사용하기 2019년 6월 19일
- Spring RESTful 웹 서비스 2019년 6월 19일
- Spring Scheduling Task 예제 2019년 6월 18일
- Grid Stack Two grids demo 예제 2019년 6월 12일
- 동적으로 추가/생성된 태그에 이벤트 추가 방법 2019년 6월 10일
- Highcharts update event 2019년 3월 26일
- spring mybatis mysql 연결 예제 2018년 5월 4일
- Spring Path Parameter 예제 2018년 2월 13일
- AngularJS $http, spring TEXT response 예제 2018년 1월 17일
- jdom2를 이용한 spring xml response(응답) 2017년 12월 5일
- jquery xml 요청, spring xml 리턴 2017년 12월 5일
- spring controller에서 get, post 동시 허용 방법 2017년 12월 5일
- mybatis, oracle procedure(오라클 커서)를 통한 데이터 조회 2017년 11월 6일
- HTTP 406 Not Acceptable in Spring, Jackson, Json 2017년 11월 6일
- jquery div show hide 예제 2016년 5월 25일
- jquery css 예제 2016년 5월 25일
- jquery selectbox 예제 2016년 5월 25일
- jquery json 예제 2016년 5월 25일
- jquery template 예제 1 2016년 5월 25일
- jquery datepicker 2016년 5월 9일
- ServletContextLister를 구현한 웹 애플리케이션 시작 시 작업 2016년 5월 2일
- jquery radiobox 2016년 4월 29일
- Web Application MessageResource 2016년 3월 8일
- org.mariadb.jdbc.internal.common.QueryException : No database selected 2016년 2월 19일
- jquery bgiframe 정리 2016년 2월 1일
- jquery each( $.each ) 2016년 1월 25일
- jquery spring – checkbox로 선택된 배열 주고 받기 2015년 8월 15일
- jquery spring ajax call 2015년 8월 15일
- spring json return 2015년 8월 15일
- spring exception – SimpleMappingExceptionResolver 2015년 8월 8일
- jQuery 동적 체크박스 제어 2015년 1월 27일
- 간단한 jquery chained selectbox 예제 2014년 12월 4일
- jquery ui tip 2014년 9월 2일