-
Notifications
You must be signed in to change notification settings - Fork 47
/
xml-to-json-converter.html
211 lines (203 loc) · 9.44 KB
/
xml-to-json-converter.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---
title: XML to JSON Converter | Developer Tools
layout: post
---
<html>
<head>
<!-- Meta tags common for website -->
{% include common-meta %}
<title>{{ page.title }}</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="description" content="This is easy to use open source tool convert XML to JSON online. You can also use this to convert JSON to XML." />
<meta name="keywords" content="online,tool,XML,json,convert,converter,web,opensource" />
<!-- CSS for the site theme -->
{% include theme-css %}
<!-- Annoying IE fixes -->
{% include ie-fixes %}
</head>
<body class="hold-transition skin-green sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">
<!-- header tag from theme -->
{% include theme-header %}
<!-- Sidebar for the whole website -->
{% include theme-sidebar %}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Main content -->
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h1 class="box-title">Convert XML Data To JSON Format</h1>
</div>
<!-- /.box-header -->
<!-- form start -->
<div class="box-body">
<form role="form">
<div class="form-group">
<label for="xml">XML Data</label>
<textarea class="form-control" rows="10" id="xml" placeholder="Enter your XML data here" autofocus></textarea>
</div>
</form>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-xs-3">
<button type="button" class="btn btn-info" id="convert2json">Convert to JSON <i class="fa fa-fw fa-arrow-right"></i></button>
</div>
</div>
</div>
<!-- /.box-footer -->
</div>
</div>
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Copy Your JSON Data From Here</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="form-group">
<label for="json">JSON Data</label>
<textarea class="form-control" id="json" rows="10" placeholder="Enter your JSON data here"></textarea>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-xs-1">
<button type="button" class="btn btn-info" id="convert2xml"><i class="fa fa-fw fa-arrow-left"></i> Convert to XML</button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="content">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">About XML to JSON Converter Tool</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>This is a free online tool to convert a XML format data into a JavaScript JSON object. You can also use the same tool to convert it back from JSON to XML. The XML input needs to be valid otherwise JSON translation will not happen.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What is a XML?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>XML or eXtended Markup Language is a popular format to store and transfer data. Many web services provide data in XML format. A popular format of XML is RSS feeds. Almost all blogs and website offer RSS feeds that are xml format data.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What Is JSON Format?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>JSON (JavaScript Object Notation) is way to represent data in JavaScript object format. It is popular for programming purposes. Many application programs interact using JSON format data. Most of REST API development is preferred
in this format. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Can I Convert a RSS Feed Data To JSON?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>Yes, RSS feed is a valid xml format and this tool can convert rss feed data to a JSON format data. You just need to copy/paste the RSS Feed content into our XML input box and it can convert it.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Can I Convert a ATOM Feed Data To JSON?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>Yes, ATOM feed is a valid xml format and this tool can convert ATOM feed data to a JSON format data. You just need to copy/paste the ATOM Feed content into our XML input box and it can convert it.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Why Convert From XML to JSON?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>XML data can be easy to read for human, however JSON data format can be used by JavaScript and other software easily. Many tools may support JSON format and you can import your data by simply converting from XML to JSON.</p>
</div>
<!-- /.box-body -->
</div>
</section>
{% include addthis %}
</div>
<!-- /.content-wrapper -->
{% include theme-footer %}
</div>
<!-- ./wrapper -->
{% include theme-bottom-js %}
</body>
<script src="plugins/selectOnFocus/jquery.selectOnFocus.min.js"></script>
<script src="plugins//xml2json/xml2json.min.js"></script>
<script>
var escapeIt = function(txt) {
return $("<div>").text(txt).html();
};
var unescapeIt = function(txt) {
var unescaped = $("<textarea/>").html(txt).text();
if (escapeIt(unescaped) == txt) {
return unescaped;
} else {
return txt;
}
};
var parseJsonSafe = function(input) {
var parsed;
try {
parsed = $.parseJSON(input);
}catch(e) {
console.log('Invalid JSON');
}
return parsed;
};
var x2js = new X2JS();
$(document).ready(function() {
$("#convert2json").click(function(){
var input = $("#xml").val();
if(input) {
var json = x2js.xml_str2json(input);
if(json) {
$("#json").val(JSON.stringify(json));
} else {
console.log("Invalid JSON data, unable to parse");
}
}
});
$("#convert2xml").click(function(){
var input = parseJsonSafe($("#json").val());
if(input) {
var xml = x2js.json2xml_str(input);
if(xml) {
$("#xml").val(xml);
}
}
});
$("#xml").selectOnFocus();
$("#json").selectOnFocus();
$('#converters-category').addClass('active');
});
</script>
</html>