Table of Contents

Class ByteArrayExtensions

Namespace
Cuemon.Extensions.Xml
Assembly
Cuemon.Extensions.Xml.dll

Extension methods for the byte[].

public static class ByteArrayExtensions
Inheritance
ByteArrayExtensions

Examples

The following example demonstrates how to convert a byte array to an XmlReader using the ByteArrayExtensions class.

using System;
using System.Text;
using System.Xml;
using Cuemon.Extensions.Xml;

namespace MyApp.Examples;

public class ByteArrayExtensionsExample
{
    public void Demonstrate()
    {
        byte[] xmlData = Encoding.UTF8.GetBytes("<root><item>Value</item></root>");

        // Convert the byte array to an XmlReader
        using (XmlReader reader = xmlData.ToXmlReader())
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    Console.WriteLine(reader.Name);

}}}}
}

Methods

ToXmlReader(byte[], Action<XmlReaderSettings>)

Converts the given value to an XmlReader.

public static XmlReader ToXmlReader(this byte[] value, Action<XmlReaderSettings> setup = null)

Parameters

value byte[]

The byte[] to extend.

setup Action<XmlReaderSettings>

The XmlReaderSettings which may be configured.

Returns

XmlReader

An XmlReader representation of value.