Created
December 7, 2012 12:43
-
-
Save rarous/4233029 to your computer and use it in GitHub Desktop.
Nalezení elementu v XSD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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