Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display next two events by date

Status
Not open for further replies.

ha1ls45

Programmer
Feb 20, 2005
105
0
0
US
Hi everyone,
I am pretty new to xml. I am trying to code an html page to display the next two events in my xml document by date. If today is April 2nd, I would like to display the lines in the xml file for tonight and tomorrow.

Here is my xml file:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<upcoming_shows>
 <show>
    <date>April 1st</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>April 2nd</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>April 7th</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>April 8th</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
</upcoming_shows>

How can I do this?

Thanks,
Ha1ls45

Thanks,
Ha1ls45
 
I am not aware of any function that does arithmetic on ordinal numbers. Any chance on getting those dates in cardinal numbers?

Tom Morrison
 
Hmm...as long as I can say, "display the next two events (including todays) somehow still. Would I be able to do that?

Thanks,
Ha1ls45
 
What are you using at the moment? XSL?

Whatever language you're using to transform the XML, it will be much easier to process the date in a standard format. The best would be the W3C date format:


So, your XML should look like:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<upcoming_shows>
 <show>
    <date>2006-04-01</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>2006-04-02</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>2006-04-07</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
 <show>
    <date>2006-04-08</date>
    <venue>Venue 1</venue>
    <citystate>City, State</citystate>
    <time>TBA</time>
  </show>
</upcoming_shows>
Although you could write a function to do it with your XML, its much easier and better to do it like this.

Jon

"I don't regret this, but I both rue and lament it.
 
The point is, 'April 1st' is not any standardized representation of a date, despite that you can read it and presumably understand what it means. The lack of standardization most likely means that your ability to do date arithmetic on the field, needed to determine what the next two events are based upon today's date, is improbable without writing a customized function of some sort.

So, given the question you are asking, with its lack of detail, my answer would be, "No, you cannot do that." If you would provide more detail about what programming environment you are using, you might get a different, perhaps even better, answer.

Tom Morrison
 
Okay, I can change the date format wo the W3C format. Not a problem! :) The website that I'd like to incorporate this into is just in HTML and CSS. I figured out how to display them all, but I would just like to limit that list down to the next two events in line. I am just confused as to how I should go about doing this. Do I need to use a JS or VB script to do this or is it possible to do it in XML itself (doesn't sound like it since it's like HTML?)? Just a point in the right direction would be very helpful! :)

Thanks,
Ha1ls45
 
The easiest way depends on what technologies you are using at the moment.

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top