# HG changeset patch # User František Kučera # Date 1637696285 -3600 # Node ID b30965489f42a134779344ba74919668497cb807 # Parent 4b938619848b2ded1993216c29563a34947781a0 fix raw-xml formatting (remove XML declaration) diff -r 4b938619848b -r b30965489f42 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Sun Feb 21 23:52:46 2021 +0100 +++ b/src/XMLTableCommand.h Tue Nov 23 20:38:05 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""); }