diff --git a/ext/simplexml/tests/bug38354.phpt b/ext/simplexml/tests/bug38354.phpt
new file mode 100644
index 00000000000..8b3b2a2a610
--- /dev/null
+++ b/ext/simplexml/tests/bug38354.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #38354 (Unwanted reformatting of XML when using AsXML)
+--SKIPIF--
+
+--FILE--
+
+ Item Two
+'
+);
+
+foreach ($xml->xpath("//*") as $element) {
+ var_dump($element->asXML());
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(101) "
+
+ Item Two
+
+"
+string(66) "
+ Item Two
+"
+string(25) "Item Two"
+Done