Ok, I have an XML in this format:
[code]<?xml version="1.0" encoding="utf-8"?>
[/code]
Ok, I have a developed a few methods that work, but I need to further their functionality, and I have reached a roadblock (due to my lack of skill!).
Here is an example of a method that checks to see if a Guild guid exists:
[code]bool gDoesExist = iCurrentObject.Elements("Guilds").Elements("Guild").Attributes("guid").Any(w => w.Value.Equals(guid));
if (gDoesExist)
{
Debug.WriteLine("Guild " + guid + " has been found, the player will be added to this Guild list");
}
else
{
Debug.WriteLine("Guild : " + guid + " was not found, adding new guild and player to the new guild's list");
}[/code]
This works fine, and here is my code to check to see if a Player exists:
[code]bool pDoesExist = iCurrentObject.Elements("Guilds").Elements("Guild").Elements("Player").Attributes("guid").Any(w => w.Value.Equals(playerguid));
if (pDoesExist)
{
Debug.WriteLine("Player: " + playerguid + " does exist");
}
else
{
Debug.WriteLine("Player: " + playerguid + " does not exist");
}[/code]
This works fine too.
Here is where I run into the roadblock, since a Player's Guild can change, I need to be able to check to see if a Player exists in all Guilds (which I already have accomplished), but then I need to store the value of that player's parent node's guid attribute.
Can someone help me develop this method? I really am at a loss and I have been reading and trying for DAYS to accomplish this!
PS: I am trying to stick to Linq using XML, and I don't want to deserialize to a class then write methods outside my XDocument object.