-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (118 loc) · 6.11 KB
/
index.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="Free Online XML To JSON Converter">
<meta name="description" content="The tool will convert a XML file to JSON format.">
<link rel="stylesheet" href="./files/bootstrap.min.css">
<script src="./files/jquery.min.js" type="text/javascript"></script>
<script src="./files/bootstrap.min.js" type="text/javascript"></script>
<title>XML To JSON Converter</title>
<script src="./files/localread.js" type="text/javascript"></script>
<script src="./files/filesaver.js" type="text/javascript"></script>
<script src="./files/csvsup.js" type="text/javascript"></script>
<script src="./files/xmltojson.nocache.js" type="text/javascript"></script>
<link rel="icon" type="image/png" href="files/xmltojson.png">
<link rel="stylesheet" href="./files/nav.css">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130695671-1"></script>
<script type="text/javascript">function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-130695671-1");</script>
<script type="text/javascript">
function assignText(s) {
document.getElementById('txt1').value = s;
document.getElementById('btnRun').click();
}
function runit(s) {
var t;
var msg='Invalid XML entered.';
if(s.trim()!="") {
try {
t=xmlToJson(s);
if(t!="null" && t!="undefined")document.getElementById('txta').value = t;
}catch (e) {
alert(msg);
return;
}
if(!t || t=="null") {alert(msg); }
}
}
</script>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<a href="https://xmltojson.github.io/">
<div id="logo">
<img height="120" src="./files/xmltojson.png" alt="Home Page">
</div>
</a>
</div>
<div class="col-md-9">
<div id="site-title">
<div class="pageHeader">
<h1>Convert XML To JSON</h1>
</div>
<div class="row">
<div class="container-fluid pageSubheader">
<h2>Use this tool to convert XML into JSON format.</h2>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<br>
Enter your data below and Press the Convert button.
The output will display below the Convert button. <br>
See also <a href="https://xmltojson.github.io/json-to-xml.html">JSON to XML</a><br>
<form id="frm1" name="frm1" class="form-inline" onsubmit="return false">
<div class="form-group">
<b>Option 1 - Choose XML file here</b>
<input type="file" id="f1" class="form-control" onchange="loadTextFile(this,assignText)" title="Choose a local XML file">
Encoding <input type="text" id="txtEncoding" class="form-control" size="8" value="" onchange="loadTextFile(document.getElementById('f1'),assignText)" title="Enter encoding for input file or empty for default">
<br><b>Option 2 - Enter an URL</b> <input type="text" size="40" value="" name="url" id="url" class="form-control" title="Enter the URL of a web page returning XML">
<input type="button" id="btnUrl" class="btn btn-primary" value="Load URL" title="Load XML via URL" onclick="loadURL(document.getElementById('url').value)">
<br><b>Option 3 - Paste into Text Box below</b>
</div>
</form></div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6">
<div class="form-group">
<input type="button" value="Clear Input" class="btn btn-primary" onclick="window.location.reload(true)">
<input type="button" value="Format XML" class="btn btn-primary" onclick="document.getElementById('txt1').value=formatXml(document.getElementById('txt1').value)" title="Format XML below to look pretty">
Examples:
<input type="button" value="1" class="btn btn-primary" title="Load and run example" onclick="document.getElementById('txt1').value=getExampleXml(1);document.getElementById('btnRun').click()">
<input type="button" value="2" class="btn btn-primary" title="Load and run example" onclick="document.getElementById('url').value='http://www.w3schools.com/xml/simple.xml';document.getElementById('btnUrl').click()">
<textarea class="form-control" rows="15" cols="80" id="txt1" placeholder="XML Data" onchange="if(this.value!='')runit(this.value)" wrap="soft"></textarea>
</div>
<div class="form-group form-inline">
<label>Save your result:</label>
<input type="text" size="15" id="fn1" value="convertxml" class="form-control" title="Enter filename without extension">.xml
<input type="button" class="btn btn-primary" value="Download Result" onclick="saveFile(document.getElementById('txt1').value,'xml','fn1')">
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="form-group">
<input type="button" id="btnRun" value="Convert XML To JSON" class="btn btn-primary" title="Convert XML To JSON" onclick="runit(document.getElementById('txt1').value)">
<br>
<textarea id="txta" rows="15" cols="80" wrap="soft" class="form-control" placeholder="JSON Output"></textarea>
</div>
<div class="form-group form-inline">
<label>Save your result:</label>
<input type="text" size="15" id="fn2" value="convertjson" class="form-control" title="Enter filename without extension">.json
<input type="button" class="btn btn-primary" value="Download Result" onclick="saveFile(document.getElementById('txta').value,'json','fn2')">
</div>
</div>
<div id="diva"></div>
</div>
<div class="row">
<div class="col-md-12">
</div>
</div>
</div>
<br>
<div class="panel-footer">
Copyright © 2015-2025 <a href="https://github.com/javadev/">Valentyn Kolesnikov</a> All Rights Reserved<span class="pull-right"> <a href="https://xmltojson.github.io/terms-of-use.html">Terms of Use</a></span>
</div>
</body></html>