--- loncom/xml/lonxml.pm	2002/01/17 17:42:34	1.149
+++ loncom/xml/lonxml.pm	2002/01/18 17:04:46	1.150
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.149 2002/01/17 17:42:34 albertel Exp $
+# $Id: lonxml.pm,v 1.150 2002/01/18 17:04:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -463,7 +463,7 @@ sub xmlparse {
 
  ($target, my @tenta) = split('&&',$target);
 
- my @stack = (); 
+ my @stack = ();
  my @parstack = ();
  &initdepth;
 
@@ -533,8 +533,14 @@ sub inner_xmlparse {
       } elsif ($token->[0] eq 'E') {
 	#clear out any tags that didn't end
 	while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
-	  &Apache::lonxml::warning('Missing tag </'.$$stack['-1'].'> in file');
-	  &end_tag($stack,$parstack,$token);
+	  my $lasttag=$$stack[-1];
+	  if ($token->[1] =~ /^$lasttag$/i) {
+	    &Apache::lonxml::warning('Using tag </'.$token->[1].'> as end tag to <'.$$stack[-1].'>');
+	    last;
+	  } else {
+	    &Apache::lonxml::warning('Found tag </'.$$stack[-1].'> when looking for </'.$token->[1].'> in file');
+	    &end_tag($stack,$parstack,$token);
+	  }
 	}
 
 	if (exists($$style_for_target{'/'."$token->[1]"})) {
@@ -613,10 +619,16 @@ sub recurse {
 			       $safeeval, $style_for_target);
       } elsif ($tokenpat->[0] eq 'E') {
 	#clear out any tags that didn't end
-	while ($tokenpat->[1] ne $innerstack[$#innerstack] 
+	while ($tokenpat->[1] ne $innerstack[$#innerstack]
 	       && ($#innerstack > -1)) {
-	  &Apache::lonxml::warning('Missing tag </'.$innerstack['-1'].'> in style');
-	  &end_tag(\@innerstack,\@innerparstack,$tokenpat);
+	  my $lasttag=$innerstack[-1];
+	  if ($tokenpat->[1] =~ /^$lasttag$/i) {
+	    &Apache::lonxml::warning('Using tag </'.$tokenpat->[1].'> as end tag to <'.$innerstack[-1].'>');
+	    last;
+	  } else {
+	    &Apache::lonxml::warning('Found tag </'.$innerstack[-1].'> when looking for </'.$tokenpat->[1].'> in file');
+	    &end_tag(\@innerstack,\@innerparstack,$tokenpat);
+	  }
 	}
 	$partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat,
 			       \@innerstack, \@innerparstack, \@pat,
@@ -936,7 +948,7 @@ sub parstring {
   foreach (@{$token->[3]}) {
     unless ($_=~/\W/) {
       my $val=$token->[2]->{$_};
-      $val =~ s/([\%\@\\])/\\$1/g;
+      $val =~ s/([\%\@\\\"])/\\$1/g;
       #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
       $temp .= "my \$$_=\"$val\";"
     }