public
Created

Phonegap Xml to Json Example

  • Download Gist
data.xml
XML
1 2 3 4 5 6 7 8 9 10
<?xml version="1.1" encoding="utf-8"?>
<employees>
<employee>
<name>Abc</name>
</employee>
<employee>
<name>Xyz</name>
</employee>
</employees>
xml_test.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="jquery.js"></script>
<script src="lib/jquery.xml2json.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
function readXml(){
$.get('data.xml', function(xml){
var employees = $.xml2json(xml);
console.log(employees)
alert(employees.employee[0].name);
});
}
</script>
</head>
<body>
<button onclick="readXml()">Read Xml</button>
</body>
</html>a

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.