ASP. NET Error: XML literal cannot appear here unless it is enclosed in parentheses

135 views Asked by At

I am attempting to port some old asp to asp.net. Following this Microsoft tutorial! I am going through the errors and this XML one has me stuck. I have placed the opening and closing parenthesis in several places, but I am still getting the error. I'm sure this is something I'm overlooking, so any help is welcomed.

IF AAP><"" or EXECCOMM><"" or Immigration><"" or MgrMember><"" or OSHA><"" or StratPlan><"" or WageHour><"" or ERISA><"" or Health><"" or Litig><"" or OffHead><"" or PICCOMM><"" or Traditional><"" or WorkComp><""  then
   BodyText=Replace(BodyText, "@@@SPECEmail@@@", "<b>Special E-mail Groups: </b>")
1

There are 1 answers

2
Bruno Lowagie On

Please read this FAQ entry on MSDN:

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.

You have a lot of < and > characters in your statement and that confuses the compiler.

Also: >< needs to be <> as explained in the comment by Andrew Morton.

So try changing your code to:

IF (AAP<>"") OR (EXECCOMM<>"") OR (Immigration<>"") OR (MgrMember<>"") OR (OSHA<>"") OR (StratPlan<>"") OR (WageHour<>"") OR (ERISA<>"") OR (Health<>"") OR (Litig<>"") OR (OffHead<>"") OR (PICCOMM<>"") OR (Traditional<>"") OR (WorkComp<>"")  THEN
    BodyText=Replace(BodyText, "@@@SPECEmail@@@", "<b>Special E-mail Groups: </b>")