Skip to content

Instantly share code, notes, and snippets.

@rarous
Created December 7, 2012 12:43
Show Gist options
  • Select an option

  • Save rarous/4233029 to your computer and use it in GitHub Desktop.

Select an option

Save rarous/4233029 to your computer and use it in GitHub Desktop.
Nalezení elementu v XSD
IEnumerable<XmlSchemaElement> FindElements(XmlSchemaObjectCollection items, string elementName)
{
foreach (XmlSchemaObject item in items)
{
var el = item as XmlSchemaElement;
if (el != null && el.Name == elementName)
return new[] { el };
var ct = item as XmlSchemaComplexType ?? el.SchemaType as XmlSchemaComplexType;
if (ct == null)
continue;
var sq = ct.Particle as XmlSchemaGroupBase;
if (sq != null)
{
var findElements = FindElements(sq.Items, elementName);
if (findElements.Any())
return findElements;
}
}
return Enumerable.Empty<XmlSchemaElement>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment