Thanks Margaret. Thats pretty much what I'm doing too. Just a FYI, j2sdk
1.4.0 will offer a replaceAll method into the String class. That should make
this method alot cleaner. It will take a String regular expression that can
do matches of patterns.
>From the 1.4.0 docs.
String replaceAll(String regex, String replacement)
Replaces each substring of this string that matches the given
regular expression with the given replacement.
Apache has a subproject called regexp that this seems to be modeled after.
I'll have to see if that offers any significant benefit for heavy XML
processing.
Thanks.
-Tim
-----Original Message-----
From: Margaret Fisk [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 11:15 AM
To: [EMAIL PROTECTED]
Subject: Re: XML reformatting
We had to create our own function that converts the strings. What we did was
identify the information we were pulling in that has special characters and
then review it character by character. Though not fast, it is effective. On
the other hand, we just use it to convert strings that are less than 256
characters long.
Margaret
-----Original Message-----
From: Chen, Gin [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 8:17 AM
To: [EMAIL PROTECTED]
Subject: Re: XML reformatting
Thanks Don. Not a bad idea but CDATA sections just make parsing a pain in
the butt. :P
-Tim
-----Original Message-----
From: McHodgkins Don [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 11:15 AM
To: [EMAIL PROTECTED]
Subject: Re: XML reformatting
Not sure this is the best way but it is one way. You can use the CDATA
Section for XML. CDATA sections begin with the string "<![CDATA[" and end
with the string "]]>":] Here is an example
<![CDATA[<greeting>Hello, world!</greeting>]]>
Don
[EMAIL PROTECTED] writes:
<< Hi all,
I have an application that uses XML data from a Servlet. The XML is
not in a file. Rather, it is dynamically generated. I have problems with
some special chars within the actual xml files themselves.
For example if a value in the XML was "children < 3". I would have a
problem
cause "<" is a reserved symbol. I have to replace each occurence of this
and
other reserved symbols with "<" and other html/xml friendly versions of
these.
The function to do so is messy and long for something like this.
My question is: is there some type of utility class that already
does this? And if so, is the performance any better than writing one
urself?
I know that response.encodeURL can encode an URL to do something
like this but this is not a URL. Its an entire XML document.
Thanks,
-Tim
[EMAIL PROTECTED]
727-738-3000 x6549 >>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html