|
VB.NET version of the above code would be
Dim parentElement As XmlSchemaElement
For Each parentElement In schema.Elements.Values
'Try Casting to complex type
Dim ct As XmlSchemaComplexType
Try
ct = DirectCast(parentElement.ElementType, XmlSchemaComplexType)
Catch ex As InvalidCastException
ct = Nothing
End Try
If Not ct Is Nothing Then
Dim seq As XmlSchemaSequence = DirectCast(ct.ContentTypeParticle, XmlSchemaSequence)
'Assuming its a sequence of elements
Dim p As XmlSchemaParticle
For Each p In seq.Items
'Check if particle in seq is XmlSchemaElement
Dim elem As XmlSchemaElement
Try
elem = DirectCast(p, XmlSchemaElement)
Catch ex As InvalidCastException
elem = Nothing
End Try
If Not elem Is Nothing Then
Console.WriteLine(elem.QualifiedName.ToString());
End If
Next
End If
Next
|