Hello everyone,
I want to make a page that select distinct values for one person from an XML file into a table. The XML has multiple entry's for this person. I can get all of the data, or just the first one, but I want all of one person, represented by his or hers "INLOGKODE" . I try it with a loop, while a condition is true. It just does n't work this way I guess...
Here's what I've got so far:
The XML:( History.xml on the server uploaded)
The site is in Wordpress, I extract the currently logged in user in PHP and then pass it to Javascript on the page:
I tried this "with" loop, but get an error:
missing : after property id
Anyone any idea? Or maybe just a wrong method for what I want? Some help would be appreciated..
I want to make a page that select distinct values for one person from an XML file into a table. The XML has multiple entry's for this person. I can get all of the data, or just the first one, but I want all of one person, represented by his or hers "INLOGKODE" . I try it with a loop, while a condition is true. It just does n't work this way I guess...
Here's what I've got so far:
The XML:( History.xml on the server uploaded)
Code:
<?xml version="1.0" encoding="UTF-8"?> <dataroot> <History> <INLOGKODE>Beer4</INLOGKODE> <DATUM>2011-04-18T00:00:00</DATUM> <SCORE>38</SCORE> <HCP-OUD>21.5</HCP-OUD> <HCP-NIEUW>20.7</HCP-NIEUW> <OPMERKING>Damesmiddag</OPMERKING> </History> <History> <INLOGKODE>Beer4</INLOGKODE> <DATUM>2011-05-17T00:00:00</DATUM> <SCORE>32</SCORE> <HCP-OUD>21</HCP-OUD> <HCP-NIEUW>21</HCP-NIEUW> <OPMERKING>ESO2011 gp1 dag2 Vnd</OPMERKING> </History> <History> <INLOGKODE>Beer4</INLOGKODE> <DATUM>2011-05-20T00:00:00</DATUM> <SCORE>19</SCORE> <HCP-OUD>21.1</HCP-OUD> <HCP-NIEUW>21.2</HCP-NIEUW> <OPMERKING>ESO2011 finale</OPMERKING> </History> <History> <INLOGKODE>Trox214</INLOGKODE> <DATUM>2011-05-08T00:00:00</DATUM> <SCORE>31</SCORE> <HCP-OUD>17.3</HCP-OUD> <HCP-NIEUW>17.4</HCP-NIEUW> <OPMERKING>Maandbeker2011 mei</OPMERKING> </History> <History> <INLOGKODE>Trox214</INLOGKODE> <DATUM>2011-07-05T00:00:00</DATUM> <SCORE>34</SCORE> <HCP-OUD>17.8</HCP-OUD> <HCP-NIEUW>17.8</HCP-NIEUW> <OPMERKING>Herenmiddag</OPMERKING> </History> <History> <INLOGKODE>Trox214</INLOGKODE> <DATUM>2011-05-10T00:00:00</DATUM> <SCORE>34</SCORE> <HCP-OUD>17.4</HCP-OUD> <HCP-NIEUW>17.4</HCP-NIEUW> <OPMERKING>Herenmiddag</OPMERKING> </History> <History> <INLOGKODE>Trox214</INLOGKODE> <DATUM>2011-04-02T00:00:00</DATUM> <SCORE>23</SCORE> <HCP-OUD>16.9</HCP-OUD> <HCP-NIEUW>17</HCP-NIEUW> <OPMERKING>Maandbeker2011 april</OPMERKING> </History> <History> <INLOGKODE>Trox214</INLOGKODE> <DATUM>2011-05-31T00:00:00</DATUM> <SCORE>33</SCORE> <HCP-OUD>17.4</HCP-OUD> <HCP-NIEUW>17.4</HCP-NIEUW> <OPMERKING>Herenmiddag</OPMERKING> </History> </dataroot>
Code:
<?php session_start();
$_SESSION["user_login"] = $DataArray[2];
$_SESSION["display_name"] = $DataArray[3];
require_once( '../../../../wp-load.php' );
global $current_user;
get_currentuserinfo();
// A welcoming (in Dutch)
echo 'Welkom '.$current_user->display_name . '. Uw inlogkode is: '.$current_user->user_login. "\n";
?>
<script type="text/javascript"> // The approach of the data XML//
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","History.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("History");
var persoon =new Object();
var persoon = "<?php echo $current_user->user_login ?>";
with ({xmlDoc.getElementsByTagName("INLOGKODE")[0].childNodes[0].nodeValue}); == persoon);
{
document.write("<tr><td>");
document.write(xmlDoc.getElementsByTagName("DATUM")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(xmlDoc.getElementsByTagName("SCORE")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(xmlDoc.getElementsByTagName("HCP-OUD")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(xmlDoc.getElementsByTagName("HCP-NIEUW")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(xmlDoc.getElementsByTagName("OPMERKING")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
missing : after property id
Anyone any idea? Or maybe just a wrong method for what I want? Some help would be appreciated..
Comment