Basically, I am trying to grab data from an XML file, and set it as a var or int. I cannot for the life of me get it to work. It seems to be copying a string of "System.IEnumerated..." or something like that instead of what the actual value of the attribute is.
My XML file is structured as such:
<Army>
<Unit childIndex="0">
<other stuff within unit>
</other stuff within unit>
</Unit>
</Army>
And there are multiple Unit tags within Army that have unique attributes and elements within them.
The program is taking say, the first Unit in Army and selecting it. Then I need to take the childIndex and grab its value to set as an int or var to use within my program. Any ideas?
Here is most of that section of code:
// finding the row index of the button you clicked
var vCurrentlySelectedRow = dataGridView1.CurrentRow.Index;
XDocument vdocument = XDocument.Load(textBox1.Text);
var vUnits = from Unit in vdocument.Descendants("Unit")
select new
{
vName = Unit.Element("Name").Value,
vType = Unit.Attribute("type").Value,
vTypeIndex = Unit.Attribute("typeindex").Value,
vChildIndex = Unit.Attribute("childID").Value,
};
string vIndexString = vCurrentlySelectedRow.ToString();
// Comparing the row index and type of the units in the XML file and tieing it to a var
var vClickedUnit = from Unit in vUnits
where Unit.vTypeIndex == vIndexString
where Unit.vType == textBox2.Text
select Unit;
This just basically finds out which units button was clicked in my program, so it knows what Unit to display from the XML file.
Thanks in advance for any help.