#6 Grande jajaja, lo que me he podido reir, en que estaría yo pensando.
No es por ser gañan, pero me hacen a mi eso y hago
Google > XML to JSON > http://www.utilities-online.info/xmltojson/#.UZx0j5O9mgQ
{
"PLAY": {
"TITLE": "The Tragedy of Hamlet, Prince of Denmark",
"FM": {
"P": [
"Text placed in the public domain by Moby Lexical Tools.",
"XML version by Jon Bosak"
]
},
"PERSONAE": {
"PERSONA": [
"CLAUDIUS, king of Denmark. ",
"HAMLET, son to the late, and nephew to the present
king.",
"HORATIO, friend to Hamlet.",
"LUCIANUS, nephew to the king."
]
}
}
}
Y auí el script:
var json = {
"PLAY": {
"TITLE": "The Tragedy of Hamlet, Prince of Denmark",
"FM": {
"P": [
"Text placed in the public domain by Moby Lexical Tools.",
"XML version by Jon Bosak"
]
},
"PERSONAE": {
"PERSONA": [
"CLAUDIUS, king of Denmark. ",
"HAMLET, son to the late, and nephew to the present king.",
"HORATIO, friend to Hamlet.",
"LUCIANUS, nephew to the king."
]
}
}
}
if (console)
console.log(json);
var html = new Array();
html.push("<h2>");
html.push(json.PLAY.TITLE);
html.push("</h2>");
if (console)
console.log(" Length of fm.p : " + json.PLAY.FM.P.length);
for(i=0; i<json.PLAY.FM.P.length; i++)
{
html.push("<p>");
html.push(json.PLAY.FM.P[i]);
html.push("</p>");
}
html.push("<h4>Personajes</h4>");
html.push("<ul>");
for(i=0; i<json.PLAY.PERSONAE.PERSONA.length; i++)
{
html.push("<li>");
html.push(json.PLAY.PERSONAE.PERSONA[i]);
html.push("</li>");
}
html.push("</ul>");
var generatedHTML = html.join("");
if (console)
console.log(generatedHTML);
document.write(generatedHTML);
PD: Aquí lo puedes ver funcionando:
http://jsfiddle.net/jNtgy/