diff options
-rw-r--r-- | src/library/scala/xml/Utility.scala | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 0991033cac..d2c6be5bac 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -201,11 +201,17 @@ object Utility extends AnyRef with parsing.TokenTests { x.nameToString(sb) if (x.attributes ne null) x.attributes.toString(sb) x.scope.toString(sb, pscope) - sb.append('>') - sequenceToXML(x.child, x.scope, sb, stripComment) - sb.append("</") - x.nameToString(sb) - sb.append('>') + if (x.child.isEmpty) + // no children, so use short form: <xyz .../> + sb.append("/>") + else { + // children, so use long form: <xyz ...>...</xyz> + sb.append('>') + sequenceToXML(x.child, x.scope, sb, stripComment) + sb.append("</") + x.nameToString(sb) + sb.append('>') + } } } |