I have a WIX XML document that contains 2,000+ file tags. I am trying to make a program using LINQ to XML that can update an attribute of each file tag. My code is as follows for loading the current attributes into a dictionary.
XElement root = XElement.Load(filePath);
XNamespace wix = @"http://schemas.microsoft.com/wix/2006/wi";
IEnumerable<string> fileId =
from seg in root.Descendants(wix + "File")
select (string)seg.Attribute(wix + "Id");
IEnumerable<string> path =
from seg in root.Descendants(wix + "File")
select (string)seg.Attribute(wix + "Source");
string[] Position1 = fileId.ToArray();
string[] Position2 = path.ToArray();
for (int i = 0; i < Position1.Length; i++)
{
xmlDataRaw.Add(Position1[i], Position2[i]);
}
now the problem is that my program says that the IEnumerable fileID and path both contain only "null" but I know that the file tag exists and that every one of them has an ID and Source attribute. Thoughts?