[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem in displaying & in XML node

Subject: Re: Problem in displaying & in XML node
From: Hari Yerram <yerram@xxxxxxxxxx>
Date: Thu, 10 Jun 1999 10:10:51 -0400
in xml
Thank you for spending time on this.

    There is another way of doing this by using the 'Replace' function of
VBScript. The replace function will replace the findstring with the
replacestring, if the findstring not found then it returns the same string.
you need not process every character and look for it. But internally it may
does the same thing(you need not bother about it :-))

Kay Michael wrote:

> > -----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 "&amp;".
>
> 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 & "&lt;"
>         ElseIf c = ">" Then
>             t = t & "&gt;"
>         ElseIf c = "'" Then
>             t = t & "&#39;"
>         ElseIf c = """" Then
>             t = t & "&#34;"
>         ElseIf c = "&" Then
>             t = t & "&amp;"
>         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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.