forked from NaturalIntelligence/fast-xml-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
145 lines (133 loc) · 6.57 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
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fast XMl Parser</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
<link rel="stylesheet" href="static/css/jquery-confirm.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<script src="lib/parser.js"></script>
<script src="static/js/jquery-confirm.min.js"></script>
</head>
<body>
<body role="document" style="background-color: #2c3e50;">
<div class="container">
<a href="https://github.com/NaturalIntelligence/fast-xml-parser"><img class="bring-up" style="position: absolute; top: 0; left: 0; border: 0;" src="https://camo.githubusercontent.com/121cd7cbdc3e4855075ea8b558508b91ac463ac2/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png"></a>
<h1 style="color:white;">Fast XML Parser</h1>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<textarea id="txtXml" name="xml" rows="15" class="form-control" placeholder="Paste XML to parse in JS/JSON">
<?xml version="1.0"?>
<any_name>
<person>
<phone>+122233344550</phone>
<name>Jack</name>
<phone>+122233344551</phone>
<age>33</age>
<married firstTime="No">Yes</married>
<birthday>Wed, 28 Mar 1979 12:13:14 +0300</birthday>
<address>
<city>New York</city>
<street>Park Ave</street>
<buildingNo>1</buildingNo>
<flatNo>1</flatNo>
</address>
<address>
<city>Boston</city>
<street>Centre St</street>
<buildingNo>33</buildingNo>
<flatNo>24</flatNo>
</address>
</person>
<person>
<phone>+122233344553</phone>
<name>Boris</name>
<phone>+122233344554</phone>
<age>34</age>
<married firstTime="Yes">Yes</married>
<birthday>Mon, 31 Aug 1970 02:03:04 +0300</birthday>
<address>
<city>Moscow</city>
<street>Kahovka</street>
<buildingNo>1</buildingNo>
<flatNo>2</flatNo>
</address>
<address>
<city>Tula</city>
<street>Lenina</street>
<buildingNo>3</buildingNo>
<flatNo>78</flatNo>
</address>
</person>
</any_name>
</textarea>
</div>
<div class="row">
<div class="col-md-8" style=" color: white;">
<input type="checkbox" id="attrNodeName"> Group all the attributes as properties of given name. <br>
<input type="checkbox" id="ignoreAttributes" checked="true"> Ignore attributes from parsing <br>
<input type="checkbox" id="ignoreNameSpace"> Remove namespace string from tag and attribute names. <br>
<input type="checkbox" id="parseNodeValue" checked="true"> Parse the value of text node to float or integer.<br>
<input type="checkbox" id="ParseAttributeValue"> Parse the value of an attribute to float or integer.<br>
<input type="checkbox" id="arrayMode"> Put the value(s) of a tag or attribute in an array. <br>
<button id="submit" class="btn btn-primary" type="button">Parse to JSON</button>
</div>
<div class="col-md-4">
<button id="validate" class="btn btn-primary" type="button">Validate XML</button>
</div>
</div>
</div>
<div class="col-md-6">
<textarea id="result" rows="30" class="form-control" placeholder="Output"></textarea>
</div>
</div>
</div>
<script>
$( document ).ready(function() {
//var parser = require("parser");
setTimeout(function(){
$.dialog({
title: '',
content: '<p style="color:black">If you like my work, plz give me a '
+ '<a href="https://github.com/NaturalIntelligence/fast-xml-parser/stargazers"><i class="fa fa2x fa-star animated infinite tada"></i></a>'
+ '.</p>'
});
}, 5000)
$('#submit').on('click', function() {
$('#result').empty();
var jsonData = parser.parse($('#txtXml').val(),buildParsingConfig());
$('#result').text(JSON.stringify(jsonData,null,4));
});
$('#validate').on('click', function() {
$('#result').empty();
try{
parser.validate($('#txtXml').val());
$('#result').text("Valid XML");
}catch(e){
$('#result').text(e);
}
});
function buildParsingConfig(){
var config = {
attributeNamePrefix : "",
attrNodeName: $("#attrNodeName").prop("checked") ? "@" : false,
textNodeName : "#text",
ignoreAttribute : $("#ignoreAttribute").prop("checked"),
ignoreNameSpace : $("#ignoreNameSpace").prop("checked"),
parseNodeValue : $("#parseNodeValue").prop("checked"),
parseAttributeValue : $("#parseAttributeValue").prop("checked"),
arrayMode : $("#arrayMode").prop("checked")
};
return config;
}
});
</script>
</body>
</html>