From 3134906c9184b5b525d1b2f3251dcbd0c3c6ab71 Mon Sep 17 00:00:00 2001
From: Lars Magne Ingebrigtsen <larsi@gnus.org>
Date: Sat, 10 Sep 2011 20:14:50 +0200
Subject: [PATCH] * xml.c (parse_region): Make the parsing work for
 non-comment-starting XML files again.

Fixes: debbugs:9144
---
 src/ChangeLog |  5 +++++
 src/xml.c     | 12 +++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 6c54d3351c6..60009bf5e0f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-10  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* xml.c (parse_region): Make the parsing work for
+	non-comment-starting XML files again (bug#9144).
+
 2011-09-10  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* image.c (gif_load): Fix calculation of bottom and right corner.
diff --git a/src/xml.c b/src/xml.c
index 8b485e73649..f0422875f7e 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -124,6 +124,8 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
 
   if (doc != NULL)
     {
+      /* If the document is just comments, then this should get us the
+	 nodes anyway. */
       xmlNode *n = doc->children->next;
       Lisp_Object r = Qnil;
 
@@ -134,9 +136,13 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
 	n = n->next;
       }
 
-      if (NILP (result))
-	result = r;
-      else
+      if (NILP (result)) {
+	/* The document isn't just comments, so get the tree the
+	   proper way. */
+	xmlNode *node = xmlDocGetRootElement (doc);
+	if (node != NULL)
+	  result = make_dom (node);
+      } else
 	result = Fcons (intern ("top"),
 			Fcons (Qnil, Fnreverse (Fcons (r, result))));
 
-- 
2.39.5