- Home /
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).
I think this tutorial is pretty good. I'm not an expert but I can try to help if you have further questions.
If you intend to use Unity a lot I recommend you start using C# or JavaScript. Personally I recommend C# as I think it's more of an industry standard (most game programmers co$$anonymous$$g from C++ background).
Thanks a lot. I've been reading that site a lot the past few days, and somehow I never stumbled upon that page. It does look really useful.
Answer by Ragwin · Dec 12, 2013 at 09:56 AM
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.
I remember reading about X$$anonymous$$LReader, but I saw a lot of options for calls and I'm still a little foggy on how to call them correctly. I will definitely look more into it more.
Will also look into figuring out about the .config files. Thanks for the response.
Your answer
![](https://koobas.hobune.stream/wayback/20220613124008im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Use editor icons in game? 2 Answers
3D detail won't update and ignores changes 0 Answers
3D Models for Unity 1 Answer
Getting ready to make RTS game like CoH, though I need help 2 Answers
How to read data on a object that is hit by a raycast? 2 Answers