# HG changeset patch # User František Kučera # Date 1637696272 -3600 # Node ID 0afd34a2b424b286843f0e360657699f8be19132 # Parent 52638b548a59e5e5d7653c387c9713b5b1ba4a0b fix raw-xml formatting (remove XML declaration) diff -r 52638b548a59 -r 0afd34a2b424 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Sat Feb 20 19:14:54 2021 +0100 +++ b/src/XMLTableCommand.h Tue Nov 23 20:37:52 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""); }