[Libguestfs] [PATCH] inspector: fix formatting of xpath result (RHBZ#1212680)

Pino Toscano ptoscano at redhat.com
Wed Apr 29 13:00:10 UTC 2015


Discard blank nodes when reading the XML from stdin, while enabling
formatting in output nodes.
---
 inspector/inspector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/inspector/inspector.c b/inspector/inspector.c
index 1863de0..412384a 100644
--- a/inspector/inspector.c
+++ b/inspector/inspector.c
@@ -769,7 +769,7 @@ do_xpath (const char *query)
   xmlSaveCtxtPtr saveCtx;
   xmlNodePtr wrnode;
 
-  doc = xmlReadFd (STDIN_FILENO, NULL, "utf8", 0);
+  doc = xmlReadFd (STDIN_FILENO, NULL, "utf8", XML_PARSE_NOBLANKS);
   if (doc == NULL) {
     fprintf (stderr, _("%s: unable to parse XML from stdin\n"), guestfs_int_program_name);
     exit (EXIT_FAILURE);
@@ -795,7 +795,7 @@ do_xpath (const char *query)
     if (nodes == NULL)
       break;
 
-    saveCtx = xmlSaveToFd (STDOUT_FILENO, NULL, XML_SAVE_NO_DECL);
+    saveCtx = xmlSaveToFd (STDOUT_FILENO, NULL, XML_SAVE_NO_DECL | XML_SAVE_FORMAT);
     if (saveCtx == NULL) {
       fprintf (stderr, _("%s: xmlSaveToFd failed\n"), guestfs_int_program_name);
       exit (EXIT_FAILURE);
-- 
2.1.0




More information about the Libguestfs mailing list