-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserList_Xml.html
More file actions
56 lines (55 loc) · 1.61 KB
/
userList_Xml.html
File metadata and controls
56 lines (55 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>RESTful 웹서비스 클라이언트(XML)</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script type="text/javascript" >
$(function(){
$.ajax({
type:'get',
url:'usersXml',
contentType:'application/xml;charset=utf-8',
dataType:'xml',
error:function(xhr,status,msg){
alert("상태값 :" + status + " Http에러메시지 :"+msg);
},
success:showResult
});
});
function showResult(xhr) {
console.log(xhr);
if($(xhr).find("status").text() == 'success') {
$(xhr).find("user").each(function(idx,user){
$('<tr>')
.append($('<td>').html($(user).find("userId").text()))
.append($('<td>').html($(user).find("name").text()))
.append($('<td>').html($(user).find("gender").text()))
.append($('<td>').html($(user).find("city").text()))
.appendTo('tbody');
});//each
}//if
}//showResult
</script>
</head>
<body>
<div class="container">
<h2>사용자 목록</h2>
<table class="table text-center">
<thead>
<tr>
<th class="text-center">아이디</th>
<th class="text-center">이름</th>
<th class="text-center">성별</th>
<th class="text-center">거주지</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</body>
</html>