Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I'm developing a desktop app that will scan a user's system for mp3 files and send their whole collection to a website. I'm assuming the best file format for sending this data to a server would be XML -- although correct me if I'm wrong.

Can someone kindly comment on whether the formatting of the sample XML file below looks okay? Thanks!

<?xml version="1.0" encoding="utf-8"?>
<collection>
    <artist name="Michael Jackson">
        <track>Beat It</track>
        <track>Thriller</track>
    </artist>
    <artist name="The Beatles">
        <track>Hey Jude</track>
        <track>Yellow Submarine</track>
    </artist>
    <artist name="Eminem">
        <track>Lose Yourself</track>
        <track>Without Me</track>
    </artist>
</collection>
share|improve this question
2  
Are you trusting metadata from the file? What about performing some sort of hashing on the file, to get ids? What is your usecase, if somebody tries to feed you false information (tracks they don't have, artists that don't exist, tracks that belong to other artists, various misspellings)? –  Clockwork-Muse Jan 3 '13 at 22:25
    
I'm actually using this for .cdg files, which AFAIK don't have ID3 tags. I'm trusting that the user has them formatted in a way that contains the artist & track title and will perform validation once the XML payload is uploaded to the server. –  user20784 Jan 3 '13 at 23:06
    
to expand on @clockwork-muse 's comment but to quote your question : "I'm developing a desktop app that will scan a user's system for mp3 files and send their whole collection to a website." ---- have you considered the situation of a user having 3tb+ of "validated" files? I know this is not your actual question but your proposed operation is suspect to say the least. What volume of data are you capable of processing realistically? That will help shape an answer to your question. –  Brandt Solovij Jan 4 '13 at 5:20
add comment

2 Answers 2

You may run into a problem if a track has more than one artist.

You'd have to enter the track for each artist again, or you'd have to only use the first artist, or you'd have to create a new "combined" artist.

Why not omit the artist→track hierarchy?

<collection>
  <track>
    <title>Thriller</title>
    <artist>Michael Jackson</artist>
  </track>
  <track>
    <title>Hey Jude</title>
    <artist>The Beatles</artist>
  </track>
</collection> 

Benefits:

  • You can add more metadata for tracks (composer, album, etc.)
  • You can add tracks without title and/or artist

If different artists may have the same name, you'd need a way to differentiate the artist elements; e.g. by using id with an ID of an artist database.

share|improve this answer
1  
I would second this and add that many people are very sloppy about keeping artist uniform - i.e. "Beatles", "The Beatles", "beatles", etc. –  Donald.McLean Jan 4 '13 at 16:14
add comment

It looks fine. I'd add a space before the xml closing tag:

<?xml version="1.0" encoding="utf-8" ?>

But surely you want more than artist and track title? Album? Maybe not much else could be figured out by the scanning. But if you can get into the ID3 tag of the MP3 file, you could get more.

An XML Validator found no problems either: http://www.w3schools.com/xml/xml_validator.asp

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.