Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:09:58+00:00 2026-06-16T17:09:58+00:00

Hoping to get some help on this: I am very thankful that a developer

  • 0

Hoping to get some help on this: I am very thankful that a developer shared this XML file with me because it should save me a lot of headache. But he told me I am on my own with how to read it. Basically I am writing a windows store app for a card game. I have a XML that is my list of cards and want to read it into a list. I get no errors, and have read XML into lists before. Any advice would be appreciated.

Here is a snippet of XML:

<?xml version="1.0" encoding="UTF-8"?><carddatabase>
    <cards>
        <card>
            <name>Tundra Kavu</name>
            <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=26805&amp;type=card" picURLHq="" picURLSt="">AP</set>
            <color>R</color>
            <manacost>2R</manacost>
            <type>Creature - Kavu</type>
            <pt>2/2</pt>
            <tablerow>2</tablerow>
            <text>{T}: Target land becomes a Plains or an Island until end of turn.</text>
        </card>
    </cards>
   </carddatabase>

Here is my serializer:

 public async void readFile()
        {
            StorageFolder myFolder = ApplicationData.Current.LocalFolder;
            StorageFile myFile = await myFolder.CreateFileAsync("cards.xml", CreationCollisionOption.OpenIfExists);

                XmlSerializer Serializer = new XmlSerializer(typeof(List<card>), new XmlRootAttribute("carddatabase"));
                string XmlString = await FileIO.ReadTextAsync(myFile);
                XmlDocument xmlDoc = await XmlDocument.LoadFromFileAsync(myFile);
                var settings = new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Auto, IgnoreWhitespace = true, IgnoreComments = true };
                var stringReader = new StringReader(XmlString);
                XmlReader reader = XmlReader.Create(stringReader, settings);

               List<card> temp = (List<card>)Serializer.Deserialize(reader);
            foreach(card x in temp)
            {
                await tempTable.InsertAsync(x);  
            }
        }

Here is my card class:

public class card
{
    public string id { get; set; }
    public string name { get; set; }
    public string manacost { get; set; }
    public string set { get; set; }
    public string color { get; set; }
    public string tablerow { get; set; }
    public string text { get; set; }
    public string type { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:10:00+00:00Added an answer on June 16, 2026 at 5:10 pm

    You can parse xml with Linq:

    XDocument xdoc = XDocument.Load(myFile);
    var cards = from c in xdoc.Descendants("card")
                select new card() {
                    name = (string)c.Element("name"),
                    manacost = (string)c.Element("manacost"),
                    set = (string)c.Element("set"),
                    color = (string)c.Element("color"),
                    tableRow = (string)c.Element("tablerow"),
                    text = (string)c.Element("text"),
                    type = (string)c.Element("type")
                };
    
    foreach(var card in cards)
        await tempTable.InsertAsync(card); 
    

    Also Linq allows you to cast values from string to other datatypes, so you can have property int TableRow { get; set; } in your class, which could be parsed as TableRow = (int)c.Element("tablerow") (or int? if tablerow element is not required).

    BTW in C# we use CamelCase names for types and properties. So, consider to have type like:

    public class Card
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string ManaCost { get; set; }
        public string Set { get; set; }
        public string Color { get; set; }
        public int TableRow { get; set; }
        public string Text { get; set; }
        public string Type { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem that I am hoping to get some help with.
hoping to get some help with this query, I've worked at it for a
I was hoping to get some help with my SQL Server script. Basically, I
I have a problem that I'm hoping to get some direction in solving -
I'm not massively familiar with this design but I am hoping to get some
this is a bit of a newbie question but hoping I can get some
Was hoping I could get a bit of a hand on this login that
Hoping to get some help with Excel 2010. I have three visible sheets. On
I was hoping to get some help assessing the best way to notated the
I have a UI problem with some CSS that I was hoping to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.