Note that there are some explanatory texts on larger screens.

plurals
  1. POGet a slice of data in Javascript or PHP
    text
    copied!<p>I'm trying to construct some app for time schedules of public transport. Most it is pretty easy, but my idea was to show only some slice of it according to the current time.</p> <p>I have pretty unfriendly XML-feed from official and the schedule data presented in it looks like this:</p> <pre><code>&lt;day day="31"&gt; &lt;hour hr="6"&gt; &lt;minutes&gt;04&lt;/minutes&gt; &lt;minutes&gt;44&lt;/minutes&gt; &lt;/hour&gt; &lt;hour hr="7"&gt; &lt;minutes&gt;08&lt;/minutes&gt; &lt;minutes&gt;51&lt;/minutes&gt; &lt;/hour&gt; […] &lt;/day&gt; &lt;day day="96"&gt; &lt;hour hr="6"&gt; &lt;minutes&gt;06&lt;/minutes&gt; &lt;/hour&gt; &lt;hour hr="7"&gt; &lt;minutes&gt;47&lt;/minutes&gt; &lt;/hour&gt; &lt;hour hr="9"&gt; &lt;minutes&gt;59&lt;/minutes&gt; &lt;/hour&gt; […] &lt;/day&gt; </code></pre> <p>Well, the first thing I should say, that this <code>day</code> tag do not means a specific day of the month or similar, it is identifies (some how, I really not sure why 31 and 96) is it working day or weekend (sat, sun). Also there could be only one, ie. for working days or for everyday(<code>&lt;day day="127"&gt;</code>).</p> <p>It is universal actual schedule, it can have only one or two different schedules for "working days ()", "each days ()" and "working days ()" + "weekends ()". That's it. No dates. Only numerical identifiers "31", "96" and "127".</p> <p>So I'm trying to collect this data and to slice closest 5 time entries from that data corresponding to the current time. So I have two questions: what would be the best way to store this data for processing and how do I process the data to get 5 entries but remember that if today will not be any more transport or less then 5 it should iterate tomorrow's schedule depending on day (working day or weekend).</p> <p>There is no problem to parse the XML. But the problem is how to parse it in most effective structure.</p> <p>As the result I plan to get something like:</p> <pre><code>18:30, 19:30, 20:30, 21:40, tomorrow 6:50 </code></pre> <p>Hope you've got me right. I'm not waiting for solutions, only advice. I can write everything by myself. Only need is concept.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload