Hi Guys,
I am writing a small app that finds all the folders IIS is referencing.
To do this I take the IIS config file and parse the xml looking for elements called IIsWebVirtualDir and look for the Path attribute.
Here is my code
XDocument doc = XDocument.Load(xmlPath);
IEnumerable<XElement> elements = doc.Elements();
foreach (XElement element in elements)
{
elementCount++;
foreach (XAttribute attribute in element.Attributes())
{
if(attribute.Name == "Path")
{
pathsFound++;
String path = attribute.Value + ",";
Console.WriteLine(path);
pathsAsStr.Append(path);
}
}
}
I have also tried using IEnumerable elements = doc.Elements().Descendants("IIsWebVirtualDir");
The code compiles but I never find more than one element. Why is this? What am I doing wrong?
I would attach the xml but its too big