[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problem in displaying & in XML node
> -----Original Message----- > From: Hari Yerram [mailto:yerram@xxxxxxxxxx] > Sent: 09 June 1999 19:48 > To: xsl-list@xxxxxxxxxxxxxxxx > Subject: Problem in displaying & in XML node > > > please look the following code. > > email = "" + Request("email"); > > sError = "<ERROR TYPE='Email_Info'>"; > sError += "<Subject>"; > sError += subject; (etc) > > The Problem is If i have '&' (ampersand) character in my XML > node ... > Is there a way to resolve it? > You need to write sError += xmlEscape(subject); where xmlEscape() is a function that substitutes special characters with their escaped forms, e.g. "&" changes to "&". Here is a very simple unoptimised VBScript version (it doesn't attempt to handle non-ASCII characters): Public Function xmlEscape(s As String) Dim i As Integer Dim t As String Dim c As String i = 1 t = "" Do While i <= Len(s) c = Mid$(s, i, 1) If c = "<" Then t = t & "<" ElseIf c = ">" Then t = t & ">" ElseIf c = "'" Then t = t & "'" ElseIf c = """" Then t = t & """ ElseIf c = "&" Then t = t & "&" Else t = t & c End If i = i + 1 Loop xmlEscape = t End Function Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|