# HG changeset patch # User František Kučera # Date 1637696292 -3600 # Node ID e91e27dc2c38a6a1efb62ee5e16d6d5752b46641 # Parent 12acb6c02d3269dd6139f20a22e572bac9d4d3c3 fix raw-xml formatting (remove XML declaration) diff -r 12acb6c02d32 -r e91e27dc2c38 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Wed Jul 28 01:40:05 2021 +0200 +++ b/src/XMLTableCommand.h Tue Nov 23 20:38:12 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""); }