Skip to content

Instantly share code, notes, and snippets.

@empirefx
Created February 4, 2012 00:06
Show Gist options
  • Save empirefx/1733906 to your computer and use it in GitHub Desktop.
Save empirefx/1733906 to your computer and use it in GitHub Desktop.
Leer XML
<?xml version="1.0" encoding="utf-8"?>
<Event status="happened">
<Song title="Physical">
<Artist name="Olivia Newton John" ID="338221">
</Artist>
<Info StartTime="21:44:11" JazlerID="4806" PlayListerID="" />
</Song>
<Song title="Be My Baby">
<Artist name="Vanessa Paradis" ID="336452">
</Artist>
<Info StartTime="21:47:47" JazlerID="1007" PlayListerID="" />
</Song>
<Song title="Can't Fight The Moonlight ">
<Artist name="Leann Rimes" ID="335842">
</Artist>
<Info StartTime="22:00:13" JazlerID="4624" PlayListerID="" />
</Song>
<Song title="I Love To Love">
<Artist name="Tina Charles" ID="336728">
</Artist>
<Info StartTime="22:11:09" JazlerID="1611" PlayListerID="" />
</Song>
<Song title="Da Ya Think I'm Sexy">
<Artist name="Rod Stewart" ID="336390">
</Artist>
<Info StartTime="22:25:06" JazlerID="1663" PlayListerID="" />
</Song>
</Event>
<?xml version="1.0" encoding="utf-8"?>
<Event status="coming up">
<Song title="Llàgrimes al Cel (Tears in Heaven)">
<Artist name="Jofre Bardagí + La Puerta de los Sueños" >
</Artist>
<Info StartTime="22:47:53" JazlerID="3243" />
</Song>
<Song title="Stand!">
<Artist name="Sly + The Family Stone" >
</Artist>
<Info StartTime="22:52:20" JazlerID="2737" />
</Song>
<Song title="Ruido">
<Artist name="Despistaos" >
</Artist>
<Info StartTime="22:59:36" JazlerID="3846" />
</Song>
</Event>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
p{
background-color:#FFFBDB;
padding:5px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
// Defino my variable global
var myObj = {};
$.ajax({
type: "GET",
url: "AirPlayHistory.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('Song').each(function(){
// Definimos el atributo tittle
myObj.tittle = $(this).attr('title');
$(this).find('Artist').each(function(){
// Definimos el atributo artist
myObj.artist = $(this).attr('name');
});
$(this).find('Info').each(function(){
// Definimos el atributo time
myObj.time = $(this).attr('StartTime');
});
// Por ultimo lo mostramos :)
$('.cancion').append( "<p>Song:"+myObj.tittle+"<br>Artist:"+myObj.artist+"<br>Time:"+myObj.time+"</p>" );
});
}
});
});
</script>
</head>
<body>
<div class="cancion"></div>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<Schedule System="Jazler">
<Event status="happening" startTime="22:44:06" eventType="song">
<Announcement Display=""/>
<Song title="Nadie">
<Artist name="Malú">
</Artist>
<Jazler ID="2932"/>
<PlayLister ID=""/>
<Media runTime="00:03:37"/>
<Expire Time="22:47:43"/>
</Song>
</Event>
</Schedule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment