A .NET library for reading and writing MetronInfo.xml files — the comic/manga metadata
format described by MetronInfo.xsd.
dotnet add package MetronInfo.Xml
- .NET 10 SDK
MetronInfo.slnx
MetronInfo.xsd # schema, embedded into the library for validation
src/MetronInfo.Xml/ # the library
MetronInfoXml.cs # Read / Write / Validate entry points
Models/ # POCOs mapped 1:1 to the XSD's types
tests/MetronInfo.Xml.Tests/ # xUnit tests, including a real MetronInfo.xml fixture
dotnet build
dotnet testusing MetronInfo.Xml; MetronInfo.Xml.Models.MetronInfo info = MetronInfoXml.Read("MetronInfo.xml"); Console.WriteLine(info.Series.Name); Console.WriteLine(info.Number);
Read also has overloads for a Stream or TextReader.
var info = new MetronInfo.Xml.Models.MetronInfo { Series = new SeriesType { Name = "Sandman", Volume = 1, StartYear = 1989 }, Number = "1", AgeRating = AgeRatingType.Mature, }; MetronInfoXml.Write(info, "MetronInfo.xml");
Write also has overloads for a Stream or TextWriter. Optional elements and attributes
you leave unset are simply omitted from the output.
Write emits the same xmlns:metroninfo, xmlns:xsd, xmlns:xsi, and xsi:schemaLocation
attributes that Metron's own tooling writes, so output stays interoperable with other readers
even though the schema itself declares no target namespace.
IReadOnlyList<string> errors = MetronInfoXml.Validate("MetronInfo.xml"); if (errors.Count > 0) { foreach (var error in errors) { Console.WriteLine(error); } }
Validate checks the document against the embedded copy of MetronInfo.xsd. It also
separately enforces the "at most one primary=\"true\"" rules on IDS/ID and URLs/URL —
the schema expresses these as XSD 1.1 xs:assert rules, which .NET's built-in XSD 1.0
validator cannot evaluate on its own.
- Models live under the
MetronInfo.Xml.Modelsnamespace and mirror the schema's element and attribute names. xs:gYear(Series.StartYear) is modeled asint.xs:datefields (CoverDate,StoreDate) and thexs:dateTimefield (LastModified) are modeled asDateTime?.