Subject: RE: Problem in displaying & in XML node From: Kay Michael <Michael.Kay@xxxxxxx> Date: Thu, 10 Jun 1999 12:46:03 +0100 |
> -----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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: how to display XML nodes having, G. Ken Holman | Thread | Re: Problem in displaying & in XML , Hari Yerram |
RE: test conditions (xsl:when) inv, Kay Michael | Date | RE: XSL/CSS Tutorials, Didier PH Martin |
Month |