A high-performance XMLTV reader and writer for .NET.
- Read and write XMLTV documents.
- Forward-only access to top-level channels and programmes.
- Preserve XMLTV date/time values with
XmlTvDateTime. - Use the standard XMLTV profile or supported compatibility profiles such as Jellyfin.
- Support .NET 8 and newer, with .NET Standard 2.0 compatibility for older runtimes.
dotnet add package XmlTvSharpXmlTvSharp supports .NET 8 and newer, including .NET 10. Older compatible runtimes can use the .NET Standard 2.0 build.
using XmlTvSharp;
using XmlTvSharp.Models;
// Load the whole XMLTV document when you want channels and programmes in memory.
XmlTvDocument document = await XmlTvReader.ReadAsync("guide.xml");
foreach (XmlTvChannel channel in document.Channels)
{
Console.WriteLine($"{channel.Id}: {channel.DisplayNames[0].Value}");
}
foreach (XmlTvProgramme programme in document.Programmes)
{
Console.WriteLine($"{programme.Start.ToXmlTvString()} {programme.ChannelId}");
}using XmlTvSharp;
using XmlTvSharp.Models;
var document = new XmlTvDocument();
// Build a minimal XMLTV document with one channel and one programme.
document.Channels.Add(new XmlTvChannel("channel-one", "Channel One"));
document.Programmes.Add(
new XmlTvProgramme(
XmlTvDateTime.Parse("20260605120000 +0000"),
"channel-one",
"News"));
await XmlTvWriter.WriteAsync(document, "guide.xml");using XmlTvSharp;
using XmlTvSharp.Models;
using var reader = new XmlTvReader("guide.xml");
// Read root <tv> metadata once, then read top-level children forward-only.
XmlTvMetadata metadata = await reader.ReadMetadataAsync();
while (await reader.ReadElementAsync() is { } element)
{
switch (element)
{
case XmlTvChannel channel:
Console.WriteLine(channel.Id);
break;
case XmlTvProgramme programme:
Console.WriteLine(programme.ChannelId);
break;
}
}XmlTvReaderandXmlTvWriterprovide forward-only read and write APIs.XmlTvReadFilterincludes channel and programme branches by ID.XmlTvReaderOptionsandXmlTvWriterOptionsconfigure compatibility profiles and XML output.
This project is licensed under the MIT License. See LICENSE.