• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

XML and JavaScript

Pikachu

Kelp is good! Yum yum!
Pronoun
he
Okay, I've discovered the sheer easiness of creating a Google Chrome extension, so now I'm trying to do just that. I'm developing a Prayer Times (a timetable thing for Muslims so that they know if it's time to pray when they're browsing the web) and I'm using XML instead of a MySQL database for the extension. This is an example of how the XML page looks:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<praytimes>
	<month name="January">
		<day value="1">
			<imsaak>05:29</imsaak>
			<fajr>05:39</fajr>
			<sunrise>06:58</sunrise>
			<dhuhr>11:56</dhuhr>
			<asr>14:36</asr>
			<sunset>16:55</sunset>
			<magrib>17:12</magrib>
			<isha>18:09</isha>
		</day>
		<day value="2">
			<imsaak>05:29</imsaak>
			<fajr>05:39</fajr>
			<sunrise>06:58</sunrise>
			<dhuhr>11:57</dhuhr>
			<asr>14:37</asr>
			<sunset>16:55</sunset>
			<magrib>17:12</magrib>
			<isha>18:09</isha>
		</day>
		<day value="3">
			<imsaak>05:29</imsaak>
			<fajr>05:39</fajr>
			<sunrise>06:58</sunrise>
			<dhuhr>11:57</dhuhr>
			<asr>14:38</asr>
			<sunset>16:56</sunset>
			<magrib>17:13</magrib>
			<isha>18:10</isha>
		</day>
	</month>
</praytimes>

I'm having a problem being able to select the times of a specific date in Javascript. Say I want the time for "asr" on the "1" of "January". How would I do that in JavaScript? I want to be able to change months and days as well. This is what I have so far in JavaScript:
Code:
<html>
<head>
<style type="text/css">
body {
  min-width: 357px;
  overflow-x: hidden;
}
</style>
</head>
<body>

<p><b>Imsaak:</b> <span id="imsaak"></span><br />
<b>Fajr:</b> <span id="fajr"></span></p>

<script type="text/javascript">
xhttp = new XMLHttpRequest()

xhttp.open("GET","praytimes.xml",false);
xhttp.send("");
xmlDoc = xhttp.responseXML;

document.getElementById("imsaak").innerHTML = xmlDoc.getElementsByTagName("imsaak")[0].childNodes[0].nodeValue;
document.getElementById("fajr").innerHTML = xmlDoc.getElementsByTagName("fajr")[0].childNodes[0].nodeValue;
</script>
</body>
</html>

Thanks again.
 
Back
Top Bottom