# HG changeset patch # User František Kučera # Date 1637696301 -3600 # Node ID 8f424bdd7065fffa7b2bfc26e2125ae42830ae79 # Parent 6b194b17894698485f4d72f27eac7d6910d080c5 fix raw-xml formatting (remove XML declaration) diff -r 6b194b178946 -r 8f424bdd7065 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Fri Jun 11 18:59:03 2021 +0200 +++ b/src/XMLTableCommand.h Tue Nov 23 20:38: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""); }