質問編集履歴
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,79 @@
|
|
51
51
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
52
52
|
|
53
53
|
jQueryの$.ajaxを使用してxmlファイルを読み込もうと考えています。
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
###追記
|
60
|
+
|
61
|
+
コメントありがとうございます_(._.)_
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
###該当のソースコード
|
66
|
+
|
67
|
+
```xml
|
68
|
+
|
69
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
70
|
+
|
71
|
+
<info>
|
72
|
+
|
73
|
+
<item type="type01">
|
74
|
+
|
75
|
+
<id>type01</id>
|
76
|
+
|
77
|
+
<name>test1</name>
|
78
|
+
|
79
|
+
<texture_src>assets/picture1.png</texture_src>
|
80
|
+
|
81
|
+
</item>
|
82
|
+
|
83
|
+
<item type="type02">
|
84
|
+
|
85
|
+
<id>type02</id>
|
86
|
+
|
87
|
+
<name>test2</name>
|
88
|
+
|
89
|
+
<texture_src>assets/picture2.png</texture_src>
|
90
|
+
|
91
|
+
</item>
|
92
|
+
|
93
|
+
</info>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
上記のように<item>にtypeを付与し、クリックするボタンそれぞれのid属性にtypeの値を持たせ、
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
###該当のソースコード
|
106
|
+
|
107
|
+
```jquery
|
108
|
+
|
109
|
+
$(xml).find("item").each(function(){
|
110
|
+
|
111
|
+
if($(this).attr("type") == "type01"){
|
112
|
+
|
113
|
+
var src = $(this).children("texture_src").text();
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
});
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
上記のように、typeごとに子要素を探しに行く。といった感じです。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
色々試してみてうまく動いた!という感じですので、何か誤りがあるかもしれませんが...
|