Sign In/My Account | View Cart  
advertisement

Article:
 The .NET Schema Object Model
Subject: Targeting a nested child element
Date: 2004-11-15 06:36:28
From: Qoheleth
Response to: Targeting a nested child element

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 it’s 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




Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Sponsored By: