S
SM
Hello,
I have a xml file that contains the CD library of one artist. I want
to extract all the tracks from a specific CD. I was able to extract
the title of all the cd's but not the tracks of one specific CD.
How can i extract track titles from a specific CD?
Here's how my code looks like:
var xmlResponse = xmlHttp.responseXML;
xmlRoot = xmlResponse.documentElement;
var arrayCD = xmlRoot.getElementsByTagName('title');
for (var i=0; i<x.length; i++)
{
html += arrayCD.childNodes[0].nodeValue + '<br />';
}
//obtain a reference to the <div> element on the HTML page
myDiv = document.getElementById("myDivElement");
//display the HTML output
myDiv.innerHTML = "Tracks: <br />" + html;
I also notice that by specifying a number in the string
'arrayCD[2].childNodes[0].nodeValue' i can access a specific cd.
arrayCD[0].childNodes[0].nodeValue // to access cd 1
arrayCD[1].childNodes[0].nodeValue // to access cd 2
arrayCD[2].childNodes[0].nodeValue // to access cd 3
I know im close, but im kinda lost.... that's why i need your help
Here's how my xml file looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<discography>
<cd>
<title>Hello</title>
<track>
<title>I want you</title>
<title>Daydreamer</title>
<title>Melody</title>
</track>
</cd>
<cd>
<title>White</title>
</cd>
<cd>
<title>Can you</title>
</cd>
<cd>
<title>Why</title>
</cd>
<cd>
<title>Help</title>
</cd>
</discography>
Thanks
Marco
I have a xml file that contains the CD library of one artist. I want
to extract all the tracks from a specific CD. I was able to extract
the title of all the cd's but not the tracks of one specific CD.
How can i extract track titles from a specific CD?
Here's how my code looks like:
var xmlResponse = xmlHttp.responseXML;
xmlRoot = xmlResponse.documentElement;
var arrayCD = xmlRoot.getElementsByTagName('title');
for (var i=0; i<x.length; i++)
{
html += arrayCD.childNodes[0].nodeValue + '<br />';
}
//obtain a reference to the <div> element on the HTML page
myDiv = document.getElementById("myDivElement");
//display the HTML output
myDiv.innerHTML = "Tracks: <br />" + html;
I also notice that by specifying a number in the string
'arrayCD[2].childNodes[0].nodeValue' i can access a specific cd.
arrayCD[0].childNodes[0].nodeValue // to access cd 1
arrayCD[1].childNodes[0].nodeValue // to access cd 2
arrayCD[2].childNodes[0].nodeValue // to access cd 3
I know im close, but im kinda lost.... that's why i need your help
Here's how my xml file looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<discography>
<cd>
<title>Hello</title>
<track>
<title>I want you</title>
<title>Daydreamer</title>
<title>Melody</title>
</track>
</cd>
<cd>
<title>White</title>
</cd>
<cd>
<title>Can you</title>
</cd>
<cd>
<title>Why</title>
</cd>
<cd>
<title>Help</title>
</cd>
</discography>
Thanks
Marco