XmppSharp 6.0.1

dotnet add package XmppSharp --version 6.0.1                
NuGet\Install-Package XmppSharp -Version 6.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XmppSharp" Version="6.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XmppSharp --version 6.0.1                
#r "nuget: XmppSharp, 6.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XmppSharp as a Cake Addin
#addin nuget:?package=XmppSharp&version=6.0.1

// Install XmppSharp as a Cake Tool
#tool nuget:?package=XmppSharp&version=6.0.1                

XMPP#

Lightweight XMPP library.

nuget

nuget-expat

nuget-tokenizer


Supported features

Parsing

After XMPP# v6.0 we are using libexpat as default XML parser for xmpp protocol. But additional parsers can be implemented along with the lib.

You can still use older XMPP# version that includes builtin XMPP parser using XmlReader or use <i>XMPP# Tokenizer</i> package.

The class XmppSharp.Dom.XmppDocument was keep to provide basic XML parsing from file or string in a simple and fast way using .NET's XmlReader.

Element Factory

The XmppElementFactory class registers and maintains the mapping of all XML elements to their respective classes. Each element is qualified by a name (Tag name) and its namespace URI, when registered the parser will obtain this information and construct the class corresponding to the XML element. If the mapping does not exist, it will use a fallback by constructing an instance of XmppSharp.Dom.XmppElement.

Consider the example table below demonstrating how this mapping works:

Qualified Tag Name Namespace(s) Mapped Class
iq see note below XmppSharp.Protocol.Core.Iq
message see note below XmppSharp.Protocol.Core.Message
presence see note below XmppSharp.Protocol.Core.Presence
error see note below XmppSharp.Protocol.Base.StanzaError
starttls urn:ietf:params:xml:ns:xmpp-tls XmppSharp.Protocol.Tls.StartTls
success urn:ietf:params:xml:ns:xmpp-sasl XmppSharp.Protocol.Sasl.Success
stream:features http://etherx.jabber.org/streams XmppSharp.Protocol.Base.StreamFeatures
... ... ...

[!NOTE] Some cases like iq, message, presence, error (error element inside an stanza), have more than one namespace defined (because it depends on each specific namespace URI), but they are declared in the same way. The difference is that more than one namespace is assigned to this element, so the XmppElementFactory can correctly map which one it will instantiate.

<hr/>

Defining your XML elements is simple, just create a class that inherits the base class XmppSharp.Dom.XmppElement or similar, call the base constructor of the class to initialize the tag name correctly. And add the attribute [XmppTag(tagName, namespace)] for each desired tag and namespace and register the type by calling XmppElementFactory.RegisterType (or to register an entire assembly XmppElementFacotry.RegisterAssembly), eg:

// define xmpp tags
[XmppTag("bind", Namespaces.Bind)]
public class Bind : XmppElement
{
    public Bind() : base("bind", Namespaces.Bind) // call base constructor to setup this element instance.
    {
        // setup other properties...
    }
}

<hr/>

Due internal reasons we merged expat parser into main package. We no longer provide default parser using XmlReader

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on XmppSharp:

Package Downloads
XmppSharp.Expat

XMPP# expat parser implementation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.1 52 2/5/2025
5.1.0 81 1/25/2025