XML literal cannot appear here unless it is enclosed in parentheses
An XML literal declaration is used in an expression in a location that is ambiguous to the Visual Basic compiler. That is, the Visual Basic compiler cannot determine whether the less-than character (<) is intended as a comparative operator or the start of an XML literal. The following code provides an example:
VB
' Generates an error.
Dim queryResult = From element In elements _
Where <sample>Value</sample> = "Value" _
Select element
Error ID: BC31198
- Enclose the XML literal declaration in parentheses, as shown in the following example:
VB
Dim queryResult = From element In elements _
Where (<sample> Value</sample>) = "Value" _
Select element
- Modify your code to refer to an existing XML literal, as shown in the following example:
VB
Dim queryResult = From element In elements _
Where e.<sample>.Value = "Value" _
Select element
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: