diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8e2fdb2..40a735d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -158,6 +158,10 @@ REGEXP_TESTS = \
field_tokenized_with_regex.sh \
field_regex_while_regex_support_is_disabled.sh
+XML_TESTS = \
+ field_xml.sh \
+ field_xml_jsoncnf.sh
+
EXTRA_DIST = exec.sh \
$(TESTS_SHELLSCRIPTS) \
$(REGEXP_TESTS) \
@@ -167,3 +171,7 @@ EXTRA_DIST = exec.sh \
if ENABLE_REGEXP
TESTS += $(REGEXP_TESTS)
endif
+
+if ENABLE_XML
+TESTS += $(XML_TESTS)
+endif
diff --git a/tests/field_xml.sh b/tests/field_xml.sh
new file mode 100644
index 0000000..2102a32
--- /dev/null
+++ b/tests/field_xml.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# added 2021-11-14 by Theo Bertin
+# This file is part of the liblognorm project, released under ASL 2.0
+. $srcdir/exec.sh
+
+test_def $0 "XML field"
+add_rule 'version=2'
+add_rule 'rule=:%field:xml%'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "field": { "note": "This is a simple note"} }'
+
+execute 'first notesecond note'
+assert_output_json_eq '{ "field": { "note": { "one": "first note", "two": "second note" } } }'
+
+# execute '@cee: {"f1": "1", "f2": 2}'
+# assert_output_json_eq '{ "field": { "f1": "1", "f2": 2 } }'
+
+# execute '@cee: {"f1": "1", "f2": 2}'
+# assert_output_json_eq '{ "field": { "f1": "1", "f2": 2 } }'
+
+#
+# Things that MUST NOT work
+#
+execute 'This is a simple note ' # note the trailing space
+assert_output_json_eq '{ "originalmsg": "This is a simple note<\/note> ", "unparsed-data": " " }'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "originalmsg": "This is a simple note", "unparsed-data": "This is a simple note" }'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "originalmsg": "This is a simple note", "unparsed-data": "This is a simple note" }'
+
+
+cleanup_tmp_files
+
diff --git a/tests/field_xml_jsoncnf.sh b/tests/field_xml_jsoncnf.sh
new file mode 100644
index 0000000..2bbaa5e
--- /dev/null
+++ b/tests/field_xml_jsoncnf.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# added 2021-11-14 by Theo Bertin
+# This file is part of the liblognorm project, released under ASL 2.0
+. $srcdir/exec.sh
+
+test_def $0 "XML field"
+add_rule 'version=2'
+add_rule 'rule=:%{"name":"field", "type":"xml"}%'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "field": { "note": "This is a simple note"} }'
+
+execute 'first notesecond note'
+assert_output_json_eq '{ "field": { "note": { "one": "first note", "two": "second note" } } }'
+
+# execute '@cee: {"f1": "1", "f2": 2}'
+# assert_output_json_eq '{ "field": { "f1": "1", "f2": 2 } }'
+
+# execute '@cee: {"f1": "1", "f2": 2}'
+# assert_output_json_eq '{ "field": { "f1": "1", "f2": 2 } }'
+
+#
+# Things that MUST NOT work
+#
+execute 'This is a simple note ' # note the trailing space
+assert_output_json_eq '{ "originalmsg": "This is a simple note<\/note> ", "unparsed-data": " " }'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "originalmsg": "This is a simple note", "unparsed-data": "This is a simple note" }'
+
+execute 'This is a simple note'
+assert_output_json_eq '{ "originalmsg": "This is a simple note", "unparsed-data": "This is a simple note" }'
+
+
+cleanup_tmp_files
+