2
\$\begingroup\$

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>
\$\endgroup\$
3
  • 2
    \$\begingroup\$ 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)? \$\endgroup\$ Commented Jan 3, 2013 at 22:25
  • \$\begingroup\$ 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. \$\endgroup\$
    – user20784
    Commented Jan 3, 2013 at 23:06
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 4, 2013 at 5:20

2 Answers 2

3
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I would second this and add that many people are very sloppy about keeping artist uniform - i.e. "Beatles", "The Beatles", "beatles", etc. \$\endgroup\$ Commented Jan 4, 2013 at 16:14
1
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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