Javascript XML help

P

pbeast

have the following xml (named CPARKS.xml):

-<CARPARKS>
<DATE>15 May 2006</DATE>
<TIME>15:59 hrs</TIME>
-<LOCATION>
<PLACE>PGS</PLACE>
- <CARPARK>
<LOCATION>Belle Meadow</LOCATION>
<STATUS>Spaces</STATUS>
<EMPTY_PLACES>124</EMPTY_PLACES>
<CAPACITY>124</CAPACITY>
</CARPARK>
- <CARPARK>
<LOCATION>Queen St MSCP</LOCATION>
<STATUS>Spaces</STATUS>
<EMPTY_PLACES>339</EMPTY_PLACES>
<CAPACITY>339</CAPACITY>
</CARPARK>
</LOCATION>
</CARPARKS>



-------------------------------------
I'm trying to extract all the car park nodes. So it should display:
Bell Meadow, Spaces, 124, 124
Queen St MSCP, Spaces, 339, 399

Using the following function, but can only get one node for each
parking lot at a time.

<xml ID="writersXML"
SRC="CPARKS.xml"></xml>
<script language="JavaScript">
function findWriters() {
var myXML, myNodes;
var display="";
myXML= document.all("writersXML").XMLDocument;
//Put the <name> element into an object.
myNodes=myXML.getElementsByTagName("EMPTY_PLACES");
//Extract the different values using a loop.
for(var counter=1;counter<myNodes.length;counter++) {
display += myNodes.item(counter).firstChild.nodeValue +
"\n";
}
document.show.me.value=display;
}
</script>

How do i pull all the car park information?

I'm trying to extract all the car park nodes. So it should display:
Bell Meadow, Spaces, 124, 124
Queen St MSCP, Spaces, 339, 399

however, the code is just giving me one node at a time, ie
EMPTY_PLACES, etc
 
P

pbeast

I figured it out i think. thanks.

have the following xml (named CPARKS.xml):

-<CARPARKS>
<DATE>15 May 2006</DATE>
<TIME>15:59 hrs</TIME>
-<LOCATION>
<PLACE>PGS</PLACE>
- <CARPARK>
<LOCATION>Belle Meadow</LOCATION>
<STATUS>Spaces</STATUS>
<EMPTY_PLACES>124</EMPTY_PLACES>
<CAPACITY>124</CAPACITY>
</CARPARK>
- <CARPARK>
<LOCATION>Queen St MSCP</LOCATION>
<STATUS>Spaces</STATUS>
<EMPTY_PLACES>339</EMPTY_PLACES>
<CAPACITY>339</CAPACITY>
</CARPARK>
</LOCATION>
</CARPARKS>



-------------------------------------
I'm trying to extract all the car park nodes. So it should display:
Bell Meadow, Spaces, 124, 124
Queen St MSCP, Spaces, 339, 399

Using the following function, but can only get one node for each
parking lot at a time.

<xml ID="writersXML"
SRC="CPARKS.xml"></xml>
<script language="JavaScript">
function findWriters() {
var myXML, myNodes;
var display="";
myXML= document.all("writersXML").XMLDocument;
//Put the <name> element into an object.
myNodes=myXML.getElementsByTagName("EMPTY_PLACES");
//Extract the different values using a loop.
for(var counter=1;counter<myNodes.length;counter++) {
display += myNodes.item(counter).firstChild.nodeValue +
"\n";
}
document.show.me.value=display;
}

How do i pull all the car park information?

I'm trying to extract all the car park nodes. So it should display:
Bell Meadow, Spaces, 124, 124
Queen St MSCP, Spaces, 339, 399

however, the code is just giving me one node at a time, ie
EMPTY_PLACES, etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top