diff src/goodjava/xml/XmlElement.java @ 1469:21f5edab1fbf

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 14 Apr 2020 13:15:18 -0600
parents 35f3bfd4f51d
children a8c685a894b4
line wrap: on
line diff
--- a/src/goodjava/xml/XmlElement.java	Tue Apr 14 08:44:33 2020 -0600
+++ b/src/goodjava/xml/XmlElement.java	Tue Apr 14 13:15:18 2020 -0600
@@ -80,11 +80,10 @@
 		}
 	}
 
-	private static String encode(String s) {
+	public static String encode(String s) {
 		final char[] a = s.toCharArray();
 		StringBuilder buf = new StringBuilder();
-		for( int i=0; i<a.length; i++ ) {
-			char c = a[i];
+		for( char c : a ) {
 			switch(c) {
 			case '&':
 				buf.append("&amp;");
@@ -98,6 +97,9 @@
 			case '"':
 				buf.append("&quot;");
 				break;
+			case '\'':
+				buf.append("&apos;");
+				break;
 			default:
 				buf.append(c);
 			}