WebSpark.Slurper
3.1.0
See the version list below for details.
dotnet add package WebSpark.Slurper --version 3.1.0
NuGet\Install-Package WebSpark.Slurper -Version 3.1.0
<PackageReference Include="WebSpark.Slurper" Version="3.1.0" />
<PackageVersion Include="WebSpark.Slurper" Version="3.1.0" />
<PackageReference Include="WebSpark.Slurper" />
paket add WebSpark.Slurper --version 3.1.0
#r "nuget: WebSpark.Slurper, 3.1.0"
#:package WebSpark.Slurper@3.1.0
#addin nuget:?package=WebSpark.Slurper&version=3.1.0
#tool nuget:?package=WebSpark.Slurper&version=3.1.0
Slurper
Slurper is a flexible .NET library for data extraction and transformation from XML, JSON, CSV, and HTML sources. It simplifies working with structured data by providing a unified API and dynamic object capabilities.
Features
- Multiple Data Formats: Extract data from XML, JSON, CSV, and HTML sources
- Unified API: Consistent interface for all supported formats
- Dynamic Object Support: Access extracted data using dynamic properties
- Async Support: All extraction methods have asynchronous versions
- Dependency Injection: Full integration with .NET DI container
- Error Handling: Comprehensive exception types for better error handling
- Logging: Built-in logging support for diagnostics
- Extensibility: Plugin system for adding custom data extractors
- Performance Options: Streaming, parallel processing, and caching options
Quick Start
// Create a factory
var factory = new SlurperFactory();
// Get an extractor
var xmlExtractor = factory.CreateXmlExtractor();
// Extract data from a string
string xml = "<book id=\"bk101\"><author>Gambardella, Matthew</author><title>XML Developer Guide</title></book>";
var books = xmlExtractor.Extract(xml);
var book = books.First();
// Access data with dynamic properties
Console.WriteLine($"Author: {book.author}, Title: {book.title}");
// Extract from file or URL
var booksFromFile = xmlExtractor.ExtractFromFile("books.xml");
var booksFromUrl = await xmlExtractor.ExtractFromUrlAsync("https://example.com/books.xml");
Advanced Features
Using Configuration Options
var options = new SlurperOptions
{
UseStreaming = true,
EnableParallelProcessing = true,
EnableCaching = true
};
var result = await extractor.ExtractFromFileAsync("large-data.xml", options);
Dependency Injection
// In Startup.cs or Program.cs
services.AddSlurper();
// In your service class constructor
public MyService(IXmlExtractor xmlExtractor, IJsonExtractor jsonExtractor)
{
_xmlExtractor = xmlExtractor;
_jsonExtractor = jsonExtractor;
}
Custom Plugins
// Create and register a plugin
var factory = new SlurperFactory();
var yamlPlugin = new YamlExtractorPlugin();
factory.RegisterPlugin(yamlPlugin);
// Use the plugin
var plugin = factory.GetPluginForSourceType("yaml");
var data = plugin.Extract<dynamic>("yaml-content");
Documentation
For detailed examples and API documentation, see the USAGE.md file.
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Requirements
- .NET 9.0 or later
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.4)
- Microsoft.Extensions.Logging (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- System.Text.Json (>= 9.0.4)
-
net9.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.4)
- Microsoft.Extensions.Logging (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- System.Text.Json (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release 3.1.0 adds the following improvements:
- Dependency injection support
- Async methods for better performance
- Enhanced error handling
- Logging support
- Performance optimizations with streaming and caching
- Support for CSV and HTML extraction
- Removed Docker and containerization dependencies