Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

Quick little XML question...

I am looking to automate some of the calendars on our website. I've decided that the best way to go about this would be to put the information into XML, and then use aApache Velocity to iterate through and write the content to the page.

I am kind of wondering, though, as to the formatting of some of it. What I want is to create containers for each month that hold sub-containers for each event. So, for example...

<academic-calendar>
    <month>April
        <cal-list-item>
            <date>Apr. 15</date>
            <day-of-week>Friday</day-of-week>
            <event>
                <event-title>Eight Week Session 2 Withdrawal Deadline</event-title>
                <event-info>4:30 p.m.</event-info>
                <event-symbol></event-symbol>
            </event>
        </cal-list-item>
    </month>
</academic-calendar>

The thing I'm wondering about, though, is that < month > tag. I know it will work if I do it that way (my foreach loop will grab the April value and put it in my "month" container in the HTML), but is there a better way of writing this?

Any insight would be greatly appreciated. :)

Thanks!

1 Answer

Um.."I am looking to automate some of the calendars on our website. I've decided that the best way to go about this" is really not really a "little" question because even if an expert in XML saw this question they know nothing about your site (you didn't even provide a link).

As to the example you provided it seems fine to me --in which way did you want it to be "better"?

Did you want more elaborate nesting for the events?

Did you want the events xml keep separately from the months xml and have a separate set of xml that connects them (which would generally be a bit more "granular" and allow the events to be developed/coded separately from any date-time elements)?

In order to recommend better ways of doing things we have to know what your ultimate goals are..

You could just be using this as a way to learn more about XML in general, I don't know.

Or maybe you want your website to have more functionality for a user standpoint.

In which case we would have to know what you want the users to be able to do.