Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created July 13, 2012 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhavaln/3106218 to your computer and use it in GitHub Desktop.
Save dhavaln/3106218 to your computer and use it in GitHub Desktop.
Phonegap Xml to Json Example
<?xml version="1.1" encoding="utf-8"?>
<employees>
<employee>
<name>Abc</name>
</employee>
<employee>
<name>Xyz</name>
</employee>
</employees>
<!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