tests: remove uses of `xmlKeepBlanksDefault()`
[lttng-tools.git] / tests / utils / xml-utils / pretty_xml.cpp
CommitLineData
bb901ead 1/*
4b2b86f2 2 * Copyright (C) 2021 EfficiOS Inc.
bb901ead
JR
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8/*
9 * Prettyfi a xml input from stdin to stddout.
10 * This allows a more human friendly format for xml testing when problems occur.
11 */
12
051356a8
SM
13#include "common.hpp"
14
bb901ead 15#include <libxml/parser.h>
051356a8 16#include <unistd.h>
bb901ead 17
051356a8 18int main()
bb901ead
JR
19{
20 xmlDocPtr doc = NULL;
21
22 /* Init libxml. */
23 xmlInitParser();
bb901ead 24
051356a8
SM
25 {
26 xml_parser_ctx_uptr parserCtx{ xmlNewParserCtxt() };
27
28 /* Parse the XML document from stdin. */
29 doc = xmlCtxtReadFd(
30 parserCtx.get(), STDIN_FILENO, nullptr, nullptr, XML_PARSE_NOBLANKS);
31 if (!doc) {
32 fprintf(stderr, "ERR parsing: xml input invalid");
33 return -1;
34 }
bb901ead 35
051356a8
SM
36 xmlDocFormatDump(stdout, doc, 1);
37
38 xmlFreeDoc(doc);
39 }
bb901ead 40
bb901ead
JR
41 /* Shutdown libxml. */
42 xmlCleanupParser();
43
44 return 0;
45}
This page took 0.041005 seconds and 4 git commands to generate.