Reputation: 45921
I'm developing a Windows Phone 7.5 app.
I have to store 22 items with the following fields:
Name and description will be in various languages.
Now, I'm using a XML file like this:
<?xml version="1.0" encoding="utf-8" ?>
<cards>
<card id ="0" name="Mad" description="xxx" ></card>
...
</cards>
I haven't work with XML a lot, and I'm not sure which is the best way to do it.
Any advice? What do you recommend me? I need to store each name and description in different lanaguages.
Upvotes: 4
Views: 242
Reputation: 189
I would structure your xml as follows
<cards>
<card id ="0">
<name lang="en">Mad</name>
<description lang="en">xxx</description>
</card>
<card id ="1">
<name lang="fr">Brother</name>
<description lang="fr">xxx</description>
</card>
.... etc ....
</cards>
By having it in this structure you only have 1 attribute per element and it is easy to find child elements which is the data you are looking for.
Actually there is another question that goes over this XML best practices: attributes vs additional elements
Upvotes: 3
Reputation: 16827
If you only have a small number of items like this reading a whole XML file into memory is no problem, SQL does not give you much advantage. SQL comes into its own when you have large complicated databases and you need to be able to query it quickly and flexibly. If you have lots of data (to much to load into memory) and you need to selectively extract items from your database, XML is a pain (you need to parse it and implement the logic which will detect matches for your query), whereas SQL is designed for that, is lightning fast and queries can be arbitrarily complex (well, within reason).
Upvotes: 0
Reputation: 3
Reading your post and tags, I undestand you want to store this data in SQL SERVER. You can have a table with different languages, and the XML will have to contain atributes name and description according to this languages, as name_ES, name_EN, name_FR,... (the same for description).
Then, programatically, you can have a DataSet object maping your SQL SERVER table. If I'm not wrong, there's the possibility to parse your XML to this DataSet object directly.
Upvotes: 0