# HG changeset patch # User František Kučera # Date 1637696241 -3600 # Node ID 0c828326aa7b3be19034b68a635ffd9ba548d7ff # Parent fd47709ed17c4ef4ac03da280d6626125f79b28d fix raw-xml formatting (remove XML declaration) diff -r fd47709ed17c -r 0c828326aa7b src/XMLTableCommand.h --- a/src/XMLTableCommand.h Sun Nov 21 20:53:26 2021 +0100 +++ b/src/XMLTableCommand.h Tue Nov 23 20:37:21 2021 +0100 @@ -43,7 +43,10 @@ std::wstring_convert> convertor; // TODO: support also other encodings. string_t formatRawXML(string_t rawXML) { - std::wregex pattern(L"^<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\n|\n$"); + std::wregex pattern(L"^(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\\s*)+|\n$"); + // libxml sometimes returns doubled XML declaration (probably a bug), see: + // --relation ini --records '/' --attribute 'xml' string '.' --mode raw-xml # (but not for --records '//*') + // so we remove all of them and also trailing line ends (if any). return std::regex_replace(rawXML, pattern, L""); }