Skip to content

Instantly share code, notes, and snippets.

@soltys
Created August 2, 2010 09:52
Show Gist options
  • Save soltys/504412 to your computer and use it in GitHub Desktop.
Save soltys/504412 to your computer and use it in GitHub Desktop.
private void FindByRecursion(XElement element, string xmlPath)
{
var q = element.Elements();
if (q.Count() == 0)
return;
foreach (var xElement in q)
{
string newXmlPath = xmlPath + "/" + xElement.Name;
string attribute = "[";
string attributeValue = "[";
foreach (var xAttribute in xElement.Attributes())
{
attribute = attribute + xAttribute.Name + ";";
attributeValue = attributeValue + xAttribute.Name + "=" + xAttribute.Value + ";";
}
attribute = attribute.DeleteLastCharacter() + "]"; // Clean up for
attributeValue = attributeValue.DeleteLastCharacter() + "]";// last semi-collon
pathCounter.Add(xmlPath);
if (attribute != "]")
{
pathCounter.Add(newXmlPath + attribute);
}
if (attributeValue != "]")
{
pathCounter.Add(newXmlPath + attributeValue);
}
FindByRecursion(xElement, newXmlPath);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment