# HG changeset patch # User František Kučera # Date 1637696264 -3600 # Node ID 4b8641293b83670cddbe7262dc90802d9f382604 # Parent c9a158da6c320ef97a3ab957af3c13288f5b9edf fix raw-xml formatting (remove XML declaration) diff -r c9a158da6c32 -r 4b8641293b83 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Sun Oct 31 17:30:40 2021 +0100 +++ b/src/XMLTableCommand.h Tue Nov 23 20:37:44 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""); }