Created
July 13, 2012 17:44
-
-
Save dhavaln/3106218 to your computer and use it in GitHub Desktop.
Phonegap Xml to Json Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.1" encoding="utf-8"?> | |
<employees> | |
<employee> | |
<name>Abc</name> | |
</employee> | |
<employee> | |
<name>Xyz</name> | |
</employee> | |
</employees> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment