Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Practical XML Usage  »  The Task
 »  Home  »  Data Programming  »  XML  »  Practical XML Usage  »  The Task
Practical XML Usage
by Gaidar Magdanurov | Published  08/20/2006 | .NET Newbie XML | Rating:
The Task

The Task

The task is to process XML data about famous band discographies in XML format (discography files): validate discography files against schema, transform them to HTML and different XML formats and allow the visual editing of those files. The sample discography file is presented below.

<?xml version="1.0" encoding="utf-8"?>
<discography band="The Beatles" firstYear="1963" lastYear="1964">
        <title>Please Please Me</title>
            <song>I Saw Her Standing There</song>
            <song>Anna (Go to Him)</song>
            <song>Ask Me Why</song>
            <song>Please Please Me</song>
            <song>Love Me Do</song>
            <song>P.S. I Love You</song>
            <song>Baby It's You</song>
            <song>Do You Want to Know a Secret</song>
            <song>A Taste of Honey</song>
            <song>There's a Place</song>
            <song>Twist and Shout</song>
        <title>With the Beatles</title>
            <song>It Won't Be Long</song>
            <song>All I've Got to Do</song>
            <song>All My Loving</song>
            <song>Don't Bother Me</song>
            <song>Little Child</song>
            <song>Till There Was You</song>
            <song>Please Mr. Postman</song>
            <song>Roll Over Beethoven</song>
            <song>Hold Me Tight</song>
            <song>You Really Got a Hold on Me</song>
            <song>I Wanna Be Your Man</song>
            <song>Devil in Her Heart</song>
            <song>Not a Second Time</song>
            <song>Money (That's What I Want)</song>

The output HTML file for this sample discography file should be as follows.

    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>The Beatles</title>
    <h1>The Beatles - Discography (1963 - 1964)</h1>
    <h2>Please Please Me (Parlaphone, 1963)</h2>
        <li>I Saw Her Standing There</li>
        <li>Anna (Go to Him)</li>
        <li>Ask Me Why</li>
        <li>Please Please Me</li>
        <li>Love Me Do</li>
        <li>P.S. I Love You</li>
        <li>Baby It's You</li>
        <li>Do You Want to Know a Secret</li>
        <li>A Taste of Honey</li>
        <li>There's a Place</li>
        <li>Twist and Shout</li>
    <h2>With the Beatles (Parlaphone, 1963)</h2>
        <li>It Won't Be Long</li>
        <li>All I've Got to Do</li>
        <li>All My Loving</li>
        <li>Don't Bother Me</li>
        <li>Little Child</li>
        <li>Till There Was You</li>
        <li>Please Mr. Postman</li>
        <li>Roll Over Beethoven</li>
        <li>Hold Me Tight</li>
        <li>You Really Got a Hold on Me</li>
        <li>I Wanna Be Your Man</li>
        <li>Devil in Her Heart</li>
        <li>Not a Second Time</li>
        <li>Money (That's What I Want)</li>

And the output XML file should be as in the following.

<?xml version="1.0" encoding="utf-8" ?>
        <name>The Beatles</name>
            <title>Please Please Me</title>
                <title>I Saw Her Standing There</title>
                <title>Anna (Go to Him)</title>
                <title>Ask Me Why</title>
                <title>Please Please Me</title>
                <title>Love Me Do</title>
                <title>P.S. I Love You</title>
                <title>Baby It's You</title>
                <title>Do You Want to Know a Secret</title>
                <title>A Taste of Honey</title>
                <title>There's a Place</title>
                <title>Twist and Shout</title>
            <title>With the Beatles</title>
                <title>It Won't Be Long</title>
                <title>All I've Got to Do</title>
                <title>All My Loving</title>
                <title>Don't Bother Me</title>
                <title>Little Child</title>
                <title>Till There Was You</title>
                <title>Please Mr. Postman</title>
                <title>Roll Over Beethoven</title>
                <title>Hold Me Tight</title>
                <title>You Really Got a Hold on Me</title>
                <title>I Wanna Be Your Man</title>
                <title>Devil in Her Heart</title>
                <title>Not a Second Time</title>
                <title>Money (That's What I Want)</title>

I am very sorry for the lengthy listings but they should give you the idea of what are we going to get in the end.


Sponsored Links