Driving me crazy, can't read XML file

EDIT: (Another Question)

So, I’m using System.Xml.Serialization, and I was wondering if I wanted everything to be searchable (As in the Deck Database system), if I would need to make all of the pieces attribute. It seems like it, so that’s what I’m doing, just wondering if I’m crazy.

Also, this is how I’m currently doing it:

using System.Xml;
using System.Xml.Serialization;

public class Card
{ 
	[XmlAttribute("name")]
	public string Name;
	[XmlAttribute("type")]
	public string Type;
	[XmlAttribute("subtype")]
	public string Subtype;
	[XmlAttribute("element")]
	public string Element;
	[XmlAttribute("faction")]
	public string Faction;
	[XmlAttribute("")]

}

(It’s obviously not done lol) Do I need to make sure the XMLAttribute calls are the same as the names in the XML Database? I would think so, but the tutorial had them as different. Thanks again for all the help!


I’ve been searching for a few days at this point, and I’ve almost all but given up. I’m creating a TCG-like game in Unity, and I found that an XML file would be the best way to hold the cards in a database. (Although, that can probably be disputed too, just what I read).

However, when it comes to trying to read the xml file, I seem to be coming up short. I’ve tried Microsoft’s C# site, as well as Unity’s. I’m sure I’m doing something wrong, but I don’t know what. I just need a way right now to parse the xml file for the tags I’ve created, and show me a random card out of the list.

I’m slightly more comfortable in Python, so I was looking at Boo, but I really couldn’t find a lot on that either. If someone could just give me a hint at where to go to make this work, I’m sure I could figure it out, I’m just at a loss at this point.

I was really hoping I could find something similar as an open source to look at and modify, but all I’ve found were regular card games (Which looks like it needs a lot less programming, and is not as useful for what I need help with now).

You need to start off by creating the connection string to access the XML file. This is normally done by reading an XML connection configured in a .config file in .NET.

Or look up the use of an XMLReader.