-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_parse_example.js
More file actions
56 lines (49 loc) · 1.43 KB
/
xml_parse_example.js
File metadata and controls
56 lines (49 loc) · 1.43 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
function loader() {
srcCode.value = 'story=0 sequence_blocks=4 iterative_depth=2 paragraphs=2 sentences=13 season=0 weapon=0 realization=(+) story_state_machine=[]'
return
}
// function loader ()
function clear_window() {
srcTranslated.value = ''
return
}
// clear_window ()
function MD5() {
srcTranslated.value = Math.md5(srcCode.value)
return
}
// generate_MD5 ()
function translatorTool() {
/*
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
200: OK
404: page not found
*/
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(data){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
srcTranslated.value = 'Query not found.'
// srcTranslated.value += data
} else if (xmlhttp.readyState==3) {
srcTranslated.value = 'Processing..'
}
}
xmlhttp.open("GET","mysql-wn-data.synsets_II.sql.xml",true)
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x = xmlDoc.getElementsByTagName("ENTRY");
var result = []
for (var i=0; i<x.length; i++){
var DEFS = x[i].getElementsByTagName("DEFINITION")
var J = x[i].getElementsByTagName("DEFINITION").length
for(var j=0; j<J; j++){
result.push(DEFS[j].childNodes[0].nodeValue)
}
}
srcTranslated.value = result.join('\n')
}
// translatorTool ()