Coder Social home page Coder Social logo

toimik / sitemapsprotocol Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 78 KB

Parsers for sitemap / sitemap index (aka Sitemaps Protocol)

License: Apache License 2.0

C# 100.00%
sitemap xml-sitemap sitemap-xml sitemaps site-map sitemapindex sitemap-index xml-sitemaps

sitemapsprotocol's Introduction

Code Coverage Nuget

Toimik.SitemapsProtocol

.NET 8 C# Sitemap parser and Sitemap Index parser.

Quick Start

Installation

Package Manager

PM> Install-Package Toimik.SitemapsProtocol

.NET CLI

> dotnet add package Toimik.SitemapsProtocol

Usage

Sitemap.cs / SitemapIndex.cs

This example shows how to use the Sitemap class.

Usage of the SitemapIndex class is similar.

// The value that every sitemap entry's location must start with
// in order for that entry to be considered as valid
var location = new Uri("http://www.example.com");

// Create an instance of the Sitemap class
var sitemap = new Sitemap(location);

// Load the data from a Stream
using var stream = // Create a local or remote stream
await sitemap.Load(stream);

// Or load the data from a string
// var data = "...";
// sitemap.Load(data);

...

var entries = sitemap.Entries;

Console.WriteLine($"{entries.EntryCount} entries parsed:");

// Enumerate the sitemap entries
while (entries.MoveNext())
{
    var entry = entries.Current;
    Console.WriteLine(entry.Location);
    ...
}

SitemapParser.cs / SitemapIndexParser.cs

This example shows how to use the SitemapParser class.

Usage of the SitemapIndexParser class is similar.

var location = new Uri("http://www.example.com");
var parser = new SitemapParser(location);
using var stream = // Create a local or remote stream
await foreach (SitemapEntry entry in parser.Parse(stream))
{
    ...
}

Internally, Sitemap and SitemapIndex use SitemapParser and SitemapIndexParser, respectively.

sitemapsprotocol's People

Contributors

nurhafiz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.