Ok, so I have this XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Item>
<Name>Iron Repeater</Name>
<AutoReuse>true</AutoReuse>
<UseAnimation>19</UseAnimation>
<UseTime>19</UseTime>
<Width>50</Width>
<Height>18</Height>
<Shoot>1</Shoot>
<UseAmmo>1</UseAmmo>
<UseSound>5</UseSound>
<Damage>39</Damage>
<ShootSpeed>11</ShootSpeed>
<NoMelee>true</NoMelee>
<Value>200000</Value>
<Ranged>true</Ranged>
<Rarity>4</Rarity>
<Knockback>2.5</Knockback>
<CraftStack>1</CraftStack>
<CraftItem1>Wood</CraftItem1>
<CraftValue1>1</CraftValue1>
<CraftTile1>18</CraftTile1>
<FinishCrafting/>
</Item>
And it's being read similar to this:
foreach (string s in API.itemFiles)
{
using (XmlReader reader = XmlReader.Create(s))
{
string aTile;
string aStack;
string item;
string iName;
int tile;
int stack;
int iStack;
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
//Le cases here
}
}
}
}
}
}
API.itemFiles is:
public static string[] itemFiles = Directory.GetFiles(itemSave, "*.xml");
Whenever I attempt to read an XML file that way, it doesn't seem to parse the element content (I do readElementContentAsXX();) into variables or whatever, but it does seem to find the elements alright.
Is there anything I'm doing wrong? Anything I can improve on? If there are any other methods for reading XML (It'll be planning to have tons of XML files; I need it to be efficient) please say!
Thanks!