aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils')
-rw-r--r--main/src/cgeo/geocaching/utils/XmlUtils.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/utils/XmlUtils.java b/main/src/cgeo/geocaching/utils/XmlUtils.java
index 2d85950..c36fb53 100644
--- a/main/src/cgeo/geocaching/utils/XmlUtils.java
+++ b/main/src/cgeo/geocaching/utils/XmlUtils.java
@@ -16,13 +16,15 @@ public final class XmlUtils {
* @param serializer an XML serializer
* @param prefix an XML prefix, see {@link XmlSerializer#startTag(String, String)}
* @param tag an XML tag
- * @param text some text to insert
+ * @param text some text to insert, or <tt>null</tt> to omit completely this tag
* @throws IOException
*/
public static void simpleText(final XmlSerializer serializer, final String prefix, final String tag, final String text) throws IOException {
- serializer.startTag(prefix, tag);
- serializer.text(text);
- serializer.endTag(prefix, tag);
+ if (text != null) {
+ serializer.startTag(prefix, tag);
+ serializer.text(text);
+ serializer.endTag(prefix, tag);
+ }
}
/**
@@ -30,7 +32,8 @@ public final class XmlUtils {
*
* @param serializer an XML serializer
* @param prefix an XML prefix, see {@link XmlSerializer#startTag(String, String)} shared by all tags
- * @param tagAndText an XML tag, the corresponding text, another XML tag, the corresponding text, …
+ * @param tagAndText an XML tag, the corresponding text, another XML tag, the corresponding text. <tt>null</tt> texts
+ * will be omitted along with their respective tag.
* @throws IOException
*/
public static void multipleTexts(final XmlSerializer serializer, final String prefix, final String... tagAndText) throws IOException {