SubtitleEdit/subtitleedit · error · InvalidDataException

Failed to parse multiple-replace XML at {path}: {ex.Message}

Error message

Failed to parse multiple-replace XML at {path}: {ex.Message}

What it means

Wrapped exception thrown by MultipleReplaceLoader.LoadXmlRules when XmlSerializer.Deserialize fails on the multiple-replace file content. The file was read successfully but is not valid XML or does not conform to the expected GroupsRoot schema (the legacy SE4 MultipleSearchAndReplaceGroups shape). The original exception is preserved as InnerException of an InvalidDataException with the path and original message.

Source

Thrown at src/seconv/Core/MultipleReplaceLoader.cs:97

        {
            return LoadCategoryItemRules(ParseJson(content, path));
        }

        return LoadCategoryItemRules(CsvRules.Parse(content));
    }

    private static List<Rule> LoadXmlRules(string content, string path)
    {
        GroupsRoot? root;
        try
        {
            using var reader = new StringReader(content);
            var serializer = new XmlSerializer(typeof(GroupsRoot));
            root = (GroupsRoot?)serializer.Deserialize(reader);
        }
        catch (Exception ex)
        {
            throw new InvalidDataException($"Failed to parse multiple-replace XML at {path}: {ex.Message}", ex);
        }

        var rules = new List<Rule>();
        if (root is null)
        {
            return rules;
        }

        foreach (var group in root.Groups.Where(g => g.IsActive))
        {
            foreach (var rule in group.Rules.Where(r => r.Active))
            {
                if (!string.IsNullOrEmpty(rule.FindWhat))
                {
                    rules.Add(rule);
                }
            }
        }

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Open the file in an XML validator or the Subtitle Edit GUI to see the exact parse error location.
  2. If the file is actually JSON or CSV, rename it with the correct extension (.json/.csv) so the loader picks the right parser.
  3. Re-export the groups from the SE GUI (Tools > Multiple replace > export) to get a schema-valid file.
Defensive patterns

Strategy: try-catch

Try / catch

try { var rules = MultipleReplaceLoader.LoadRules(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("Failed to parse multiple-replace XML"))
{
    // ex.InnerException has the XmlException with line/position
    var xmlError = ex.InnerException;
    // Report XML parse error, suggest re-export or fix
}

Prevention

When it happens

Trigger: The multiple-replace file is selected as XML (by .xml extension or content starting with '<') but is malformed XML, has unclosed tags, invalid encoding declarations, or does not match the GroupsRoot/Group/Rule schema the deserializer expects.

Common situations: Editing the XML by hand and introducing a syntax error; using an XML file exported by a different tool with a different schema; encoding issues (e.g. BOM or declared encoding mismatch); a truncated file.

Understand the failure class

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/2d36cab60a1cfdab. Report an issue: GitHub.