Hola, el error fue mio por no pensado/incluirlo antes... el error es por que las variables que se declaron dentro de una funcion solo son accesible a esa funcion:
var v1; // Esta es una variable global
function funcion1(){
var v2; // Esta variable es visible solamente dentro de la funcion funcion1()
// v1 Podemos seguir utilizando esta variable
}
function funcion2(){
var v3; // // Esta variable es visible solamente dentro de la funcion funcion2()
// v1 Podemos seguir utilizando esta variable
// v2 Esta variable ya no es accesible
function funcion3(){
var v4; // Esta variable es visible solamente dentro de la funcion funcion3()
// v1 Podemos seguir utilizando esta variable
// v2 Esta variable ya no es accesible
// v3 Podemos seguir utilizando esta variable
}
}
Por lo que hay que declarar una variable Global para que pueda ser accesido a todas las demas funciones, en el ejemplo de AirPlayHistory, quedaria asi:
<!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>