Impossibile selezionare attributi XML dal tipo 'type'

È stato fatto riferimento a un attributo XML per un oggetto che non è di tipo XElement o IEnumerable(Of XElement). Per altre informazioni, vedere XML Attribute Axis Property.

' Generates an error.  
Dim var = "sample text".@attr  

ID errore: BC36808

Per correggere l'errore

  • Se si fa riferimento a un attributo di un oggetto, quest'ultimo deve essere fortemente tipizzato come XElement o IEnumerable(Of XElement). Di seguito è illustrato un esempio:
Dim elem As XElement = <root attr="value"/>  
Dim var = elem.@attr  

Vedi anche