Table of Contents

Class XmlUtility

Namespace
Songhay.Xml
Assembly
SonghayCore.dll

Static helper members for XML-related routines.

public static class XmlUtility
Inheritance
XmlUtility
Inherited Members

Fields

ConventionalHtmlEntities

The conventional HTML entities mapped to their respective glyphs.

public static readonly Dictionary<string, string> ConventionalHtmlEntities

Field Value

Dictionary<string, string>

Methods

CombineNavigableDocuments(IXPathNavigable?, IXPathNavigable?)

Combines two IXPathNavigable documents.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? CombineNavigableDocuments(IXPathNavigable? parentDocument, IXPathNavigable? childDocument)

Parameters

parentDocument IXPathNavigable

The IXPathNavigable “hosting” document.

childDocument IXPathNavigable

The IXPathNavigable child document.

Returns

XPathDocument

CombineNavigableDocuments(IXPathNavigable?, IXPathNavigable?, string?)

Combines two IXPathNavigable documents.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? CombineNavigableDocuments(IXPathNavigable? parentDocument, IXPathNavigable? childDocument, string? nodeQuery)

Parameters

parentDocument IXPathNavigable

The IXPathNavigable “hosting” document.

childDocument IXPathNavigable

The IXPathNavigable child document.

nodeQuery string

The XPath query to the child document location in the “hosting” document.

Returns

XPathDocument

GetInstanceRaw<T>(string?, ILogger)

Deserializes to a class instance based on the specified raw XML.

public static T? GetInstanceRaw<T>(string? xmlFragment, ILogger logger) where T : class

Parameters

xmlFragment string

The raw XML.

logger ILogger

the ILogger

Returns

T

Type Parameters

T

The specified type to deserialize.

GetInstance<T>(string?, ILogger)

Deserializes to a class instance based on the specified XML file.

public static T? GetInstance<T>(string? xmlPath, ILogger logger) where T : class

Parameters

xmlPath string

The XML file path.

logger ILogger

the ILogger

Returns

T

Type Parameters

T

The specified type to deserialize.

GetInternalMessage(string)

Returns an XML string based on the specified header and lines.

public static string GetInternalMessage(string messageHeader)

Parameters

messageHeader string

Message header.

Returns

string

GetInternalMessage(string, ReadOnlyCollection<string>?)

Returns an XML string based on the specified header and lines.

public static string GetInternalMessage(string messageHeader, ReadOnlyCollection<string>? messageLines)

Parameters

messageHeader string

Message header.

messageLines ReadOnlyCollection<string>

Message lines.

Returns

string

GetInternalMessage(string?, string?, IEnumerable<string>?)

Returns an XML string based on the specified header and lines.

public static string GetInternalMessage(string? messageHeader, string? messageCode, IEnumerable<string>? messageLines)

Parameters

messageHeader string

Message header.

messageCode string

Message code for errors, exceptions or faults.

messageLines IEnumerable<string>

Message lines.

Returns

string

GetInternalMessage(string?, string?, string[]?, XmlWriter)

Gets the conventional, XML <InternalMessage>.

public static void GetInternalMessage(string? messageHeader, string? messageCode, string[]? messageLines, XmlWriter xmlDataWriter)

Parameters

messageHeader string

Message header.

messageCode string

Message code for errors, exceptions or faults.

messageLines string[]

Message lines.

xmlDataWriter XmlWriter

The System.Xml.XmlTextWriter.

GetInternalMessage(string?, string?, string[]?, XmlWriter?, bool)

Gets the conventional, XML <InternalMessage>.

public static void GetInternalMessage(string? messageHeader, string? messageCode, string[]? messageLines, XmlWriter? xmlDataWriter, bool isFragment)

Parameters

messageHeader string

Message header.

messageCode string

Message code for errors, exceptions or faults.

messageLines string[]

Message lines.

xmlDataWriter XmlWriter

The XmlWriter.

isFragment bool

When false a new document is started.

GetInternalMessage(string, string[])

Returns an XML string based on the specified header and lines.

public static string GetInternalMessage(string messageHeader, string[] messageLines)

Parameters

messageHeader string

Message header.

messageLines string[]

Message lines.

Returns

string

GetInternalMessage(string?, string[]?, XmlWriter?)

Gets the conventional, XML <InternalMessage>.

public static void GetInternalMessage(string? messageHeader, string[]? messageLines, XmlWriter? xmlDataWriter)

Parameters

messageHeader string

Message header.

messageLines string[]

Message lines.

xmlDataWriter XmlWriter

The XmlWriter.

GetInternalMessage(string?, string[]?, XmlWriter?, bool)

Gets the conventional, XML <InternalMessage>.

public static void GetInternalMessage(string? messageHeader, string[]? messageLines, XmlWriter? xmlDataWriter, bool isFragment)

Parameters

messageHeader string

Message header.

messageLines string[]

Message lines.

xmlDataWriter XmlWriter

The XmlWriter.

isFragment bool

When false a new document is started.

GetInternalMessageDocument(string?, string?, string[]?)

Returns an XPathDocument based on the specified header and lines.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? GetInternalMessageDocument(string? messageHeader, string? messageCode, string[]? messageLines)

Parameters

messageHeader string

Message header.

messageCode string

Message code for errors, exceptions or faults

messageLines string[]

Message lines.

Returns

XPathDocument

GetInternalMessageDocument(string?, string[]?)

Returns an XPathDocument based on the specified header and lines.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? GetInternalMessageDocument(string? messageHeader, string[]? messageLines)

Parameters

messageHeader string

Message header.

messageLines string[]

Message lines.

Returns

XPathDocument

GetNamespaceManager(IXPathNavigable?)

Returns a XmlNamespaceManager with respect to the document element of the specified IXPathNavigable document.

public static XmlNamespaceManager? GetNamespaceManager(IXPathNavigable? navigable)

Parameters

navigable IXPathNavigable

The IXPathNavigable document.

Returns

XmlNamespaceManager

GetNavigableDocument(Stream?)

Returns an XPathDocument based on the specified Stream.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? GetNavigableDocument(Stream? stream)

Parameters

stream Stream

The stream.

Returns

XPathDocument

GetNavigableDocument(string?)

Returns an XPathDocument based on the specified string.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? GetNavigableDocument(string? xmlFragment)

Parameters

xmlFragment string

A well-formed XML string.

Returns

XPathDocument

GetNavigableDocument(IXPathNavigable?)

Returns an XPathDocument based on the specified XmlNode.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? GetNavigableDocument(IXPathNavigable? navigable)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

Returns

XPathDocument

Remarks

Use this member to convert XmlDocument documents.

GetNavigableNode(IXPathNavigable?, string?)

Returns an XPathNavigator based on the nodeQuery Expression toward the source document.

public static XPathNavigator? GetNavigableNode(IXPathNavigable? navigable, string? nodeQuery)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

nodeQuery string

The value to be compiled into an XPathExpression.

Returns

XPathNavigator

GetNavigableNode(IXPathNavigable?, string?, XmlNamespaceManager?)

Returns an XPathNavigator based on the nodeQuery Expression toward the source document.

public static XPathNavigator? GetNavigableNode(IXPathNavigable? navigable, string? nodeQuery, XmlNamespaceManager? nsMan)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

nodeQuery string

The value to be compiled into an XPathExpression.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

Returns

XPathNavigator

GetNavigableNodes(IXPathNavigable?, string?)

Returns an XPathNodeIterator based on the nodeQuery Expression toward the source document.

public static XPathNodeIterator? GetNavigableNodes(IXPathNavigable? navigable, string? nodeQuery)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

nodeQuery string

The value to be compiled into an XPathExpression.

Returns

XPathNodeIterator

GetNavigableNodes(IXPathNavigable?, string?, XmlNamespaceManager)

Returns an XPathNodeIterator based on the nodeQuery Expression toward the source document.

public static XPathNodeIterator? GetNavigableNodes(IXPathNavigable? navigable, string? nodeQuery, XmlNamespaceManager nsMan)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

nodeQuery string

The value to be compiled into an XPathExpression.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

Returns

XPathNodeIterator

GetNodeValue(IXPathNavigable?, string?, bool)

Returns an object for parsing and adding to a list of parameters for data access.

public static object? GetNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When true, throw an exception for null nodes.

Returns

object

GetNodeValue(IXPathNavigable?, string?, bool, object?)

Returns an object for parsing and adding to a list of parameters for data access.

public static object? GetNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, object? defaultValue)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When true, throw an exception for null nodes.

defaultValue object

Return the specified default value for “zero-length” text nodes.

Returns

object

GetNodeValue(IXPathNavigable?, string?, bool, object?, XmlNamespaceManager?)

Returns an object for parsing and adding to a list of parameters for data access.

public static object? GetNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, object? defaultValue, XmlNamespaceManager? nsMan)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When true, throw an exception for null nodes.

defaultValue object

Return the specified default value for “zero-length” text nodes.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

Returns

object

GetNodeValueAndParse<T>(IXPathNavigable?, string?, bool, T)

Returns an object for parsing and adding to a list of parameters for data access.

public static object? GetNodeValueAndParse<T>(IXPathNavigable? node, string? nodeQuery, bool throwException, T defaultValue)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The XPath string.

throwException bool

When true, throw an exception for null nodes and nodes that do not parse into the specified type.

defaultValue T

Return a boxing object for “zero-length” text nodes.

Returns

object

Type Parameters

T

The type to parse from the node value.

GetNodeValueAndParse<T>(IXPathNavigable?, string?, bool, T?, XmlNamespaceManager?)

Returns an object for parsing and adding to a list of parameters for data access.

public static object? GetNodeValueAndParse<T>(IXPathNavigable? node, string? nodeQuery, bool throwException, T? defaultValue, XmlNamespaceManager? nsMan)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The XPath string.

throwException bool

When true, throw an exception for null nodes and nodes that do not parse into the specified type.

defaultValue T

Return a boxing object for “zero-length” text nodes.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

Returns

object

Type Parameters

T

The type to parse from the node value.

GetXmlSchema(IXPathNavigable, ValidationEventHandler)

Returns an XmlSchema based on the specified navigable set and validation event handler.

public static XmlSchema? GetXmlSchema(IXPathNavigable navigable, ValidationEventHandler eventHandler)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

eventHandler ValidationEventHandler

The ValidationEventHandler with signature MyHandler(object sender, ValidationEventArgs args).

Returns

XmlSchema

GetXslResult(IXPathNavigable?, IXPathNavigable?)

Returns a XPathDocument for the transformation of the XSLT document and the XML document.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument GetXslResult(IXPathNavigable? navigableXsl, IXPathNavigable? navigableSet)

Parameters

navigableXsl IXPathNavigable

The source IXPathNavigable XSL document.

navigableSet IXPathNavigable

The source IXPathNavigable XML document.

Returns

XPathDocument

GetXslResult(IXPathNavigable?, XsltArgumentList?, IXPathNavigable?)

Returns a XPathDocument for the transformation of the XSLT document and the XML document.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument GetXslResult(IXPathNavigable? navigableXsl, XsltArgumentList? xslArgs, IXPathNavigable? navigableXml)

Parameters

navigableXsl IXPathNavigable

The source IXPathNavigable XSL document.

xslArgs XsltArgumentList

The XsltArgumentList.

navigableXml IXPathNavigable

The source IXPathNavigable XML document.

Returns

XPathDocument

GetXslString(IXPathNavigable?, IXPathNavigable?)

Returns a string for the transformation of the XSLT document and the XML document.

public static string? GetXslString(IXPathNavigable? navigableXsl, IXPathNavigable? navigableSet)

Parameters

navigableXsl IXPathNavigable

The source IXPathNavigable XSL document.

navigableSet IXPathNavigable

The source IXPathNavigable XML document.

Returns

string

GetXslString(IXPathNavigable?, XsltArgumentList?, IXPathNavigable?)

Returns a string for the transformation of the XSLT document and the XML document.

public static string? GetXslString(IXPathNavigable? navigableXsl, XsltArgumentList? xslArgs, IXPathNavigable? navigableXml)

Parameters

navigableXsl IXPathNavigable

The source IXPathNavigable XSL document.

xslArgs XsltArgumentList

The XsltArgumentList.

navigableXml IXPathNavigable

The source IXPathNavigable XML document.

Returns

string

GetXslString(IXPathNavigable?, XsltArgumentList?, IXPathNavigable?, XmlWriterSettings?)

Returns a string for the transformation of the XSLT document and the XML document.

public static string? GetXslString(IXPathNavigable? navigableXsl, XsltArgumentList? xslArgs, IXPathNavigable? navigableXml, XmlWriterSettings? settings)

Parameters

navigableXsl IXPathNavigable

The source IXPathNavigable XSL document.

xslArgs XsltArgumentList

The XsltArgumentList.

navigableXml IXPathNavigable

The source IXPathNavigable XML document.

settings XmlWriterSettings

The settings.

Returns

string

InputAs<TIn>(TIn?)

Returns an XPathDocument, converted from the specified input.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
[Obsolete("Use `ToOuterXmlString` and/or `ToXmlDocument` in `IXPathNavigableExtensions` with perhaps `XmlUtility.GetNavigableDocument` instead.")]
public static XPathDocument? InputAs<TIn>(TIn? input) where TIn : class

Parameters

input TIn

The input.

Returns

XPathDocument

Returns an XPathDocument.

Type Parameters

TIn

The Type of the input.

Remarks

This member only supports TIn as string, XmlDocument or XPathDocument.

IsNoNodeValue(IXPathNavigable?, string?, bool)

Returns true when the node has the value “no”.

public static bool IsNoNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

Returns

bool

IsNodeValue(IXPathNavigable?, string?, bool, string?)

Returns true when the node has the specified value.

public static bool IsNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, string? testValue)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

testValue string

The specified value to test with the node value.

Returns

bool

IsNodeValue(IXPathNavigable?, string?, bool, string?, StringComparison)

Returns true when the node has the specified value.

public static bool IsNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, string? testValue, StringComparison comparisonType)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

testValue string

The specified value to test with the node value.

comparisonType StringComparison

The StringComparison type.

Returns

bool

IsNodeValue(IXPathNavigable?, string?, bool, string?, XmlNamespaceManager)

Returns true when the node has the specified value.

public static bool IsNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, string? testValue, XmlNamespaceManager nsMan)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

testValue string

The specified value to test with the node value.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

Returns

bool

IsNodeValue(IXPathNavigable?, string?, bool, string?, XmlNamespaceManager, StringComparison)

Returns true when the node has the specified value.

public static bool IsNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException, string? testValue, XmlNamespaceManager nsMan, StringComparison comparisonType)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

testValue string

The specified value to test with the node value.

nsMan XmlNamespaceManager

The XmlNamespaceManager to use to resolve prefixes.

comparisonType StringComparison

The StringComparison type.

Returns

bool

IsXml(string?)

Returns true when the fragment is XML-like.

public static bool IsXml(string? fragment)

Parameters

fragment string

The fragment to test.

Returns

bool

IsYesNodeValue(IXPathNavigable?, string?, bool)

Returns true when the node has the value “yes”.

public static bool IsYesNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException)

Parameters

node IXPathNavigable

The IXPathNavigable node.

nodeQuery string

The node query string.

throwException bool

When

true

, throw an exception for null nodes.

Returns

bool

LoadXmlSchema(string?, ValidationEventHandler?)

Loads an XmlSchema based on the specified navigable set and validation event handler.

public static XmlSchema? LoadXmlSchema(string? pathToSchema, ValidationEventHandler? eventHandler)

Parameters

pathToSchema string

The valid path to an XML Schema file.

eventHandler ValidationEventHandler

The ValidationEventHandler with signature MyHandler(object sender, ValidationEventArgs args).

Returns

XmlSchema

LoadXslTransform(string?, string?)

Returns a string for the transformation of the XSLT file and the XML file.

public static string? LoadXslTransform(string? xslPath, string? xmlPath)

Parameters

xslPath string

Output path to the XSLT file.

xmlPath string

Output path to the XML file.

Returns

string

LoadXslTransform(string?, string?, string?)

Returns a string for the transformation of the XSLT file and the XML file.

public static string? LoadXslTransform(string? xslPath, string? commandName, string? xmlPath)

Parameters

xslPath string

Output path to the XSLT file.

commandName string
The value for the 
cmd

-parameter convention.

xmlPath string

Output path to the XML file.

Returns

string

LoadXslTransform(string?, XsltArgumentList?, string?)

Returns a string for the transformation of the XSLT file and the XML file.

public static string? LoadXslTransform(string? xslPath, XsltArgumentList? xslArgs, string? xmlPath)

Parameters

xslPath string

Output path to the XSLT file.

xslArgs XsltArgumentList

The XsltArgumentList.

xmlPath string

Output path to the XML file.

Returns

string

LoadXslTransformForMemoryInput(string?, string?, string?)

Returns a string for the transformation of the XSLT file and the specified IXPathNavigable in memory.

public static string? LoadXslTransformForMemoryInput(string? xslPath, string? commandName, string? xmlFragment)

Parameters

xslPath string

Output path to the XSLT file.

commandName string
The value for the 
cmd

-parameter convention.

xmlFragment string

A well-formed XML string.

Returns

string

Remarks

This convention is used in ASP.NET Web applications.

LoadXslTransformForMemoryInput(string?, string?, IXPathNavigable)

Returns a string for the transformation of the XSLT file and the specified IXPathNavigable in memory.

public static string? LoadXslTransformForMemoryInput(string? xslPath, string? commandName, IXPathNavigable navigableXml)

Parameters

xslPath string

Output path to the XSLT file.

commandName string
The value for the 
cmd

-parameter convention.

navigableXml IXPathNavigable

The IXPathNavigable in memory.

Returns

string

Remarks

This convention is used in ASP.NET Web applications.

LoadXslTransformForMemoryInput(string?, XsltArgumentList?, string?)

Returns a string for the transformation of the XSLT file and the XML in-memory fragment.

public static string? LoadXslTransformForMemoryInput(string? xslPath, XsltArgumentList? xslArgs, string? xmlFragment)

Parameters

xslPath string

Output path to the XSLT file.

xslArgs XsltArgumentList

The XsltArgumentList.

xmlFragment string

A well-formed XML string.

Returns

string

Remarks

This convention is used in ASP.NET Web applications.

MatchAllThatLooksLikeXmlMarkup()

[GeneratedRegex("<\\s*([^>]+)\\s*>")]
public static Regex MatchAllThatLooksLikeXmlMarkup()

Returns

Regex

Remarks

Pattern:

<\\s*([^>]+)\\s*>

Explanation:<br />
<pre><code class="lang-csharp">○ Match '<'.

○ Match a whitespace character greedily any number of times. ○ 1st capture group. ○ Match a character other than '>' greedily at least once. ○ Match a whitespace character atomically any number of times. ○ Match '>'.

MatchAllThatLooksLikeXmlSelfClosingTags()

[GeneratedRegex("<([^>]+)/>")]
public static Regex MatchAllThatLooksLikeXmlSelfClosingTags()

Returns

Regex

Remarks

Pattern:

<([^>]+)/>

Explanation:<br />
<pre><code class="lang-csharp">○ Match '<'.

○ 1st capture group. ○ Match a character other than '>' greedily at least once. ○ Match the string "/>".

MatchXhtmlDocTypeDeclaration()

[GeneratedRegex("\\<\\!DOCTYPE [^<]+\\>")]
public static Regex MatchXhtmlDocTypeDeclaration()

Returns

Regex

Remarks

Pattern:

\\<\\!DOCTYPE [^<]+\\>

Explanation:<br />
<pre><code class="lang-csharp">○ Match the string "<!DOCTYPE ".

○ Match a character other than '<' greedily at least once. ○ Match '>'.

MatchXmlNamedEntities()

[GeneratedRegex("\\&\\w+\\;", RegexOptions.IgnoreCase)]
public static Regex MatchXmlNamedEntities()

Returns

Regex

Remarks

Pattern:

\\&\\w+\\;

Options:<br />
<pre><code class="lang-csharp">RegexOptions.IgnoreCase</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match '&'.

○ Match a word character atomically at least once. ○ Match ';'.

MatchXmlNamespaceDeclarations()

[GeneratedRegex("\\s*(xmlns:?[^=]*=[\"][^\"]*[\"])\\s*", RegexOptions.IgnoreCase)]
public static Regex MatchXmlNamespaceDeclarations()

Returns

Regex

Remarks

Pattern:

\\s*(xmlns:?[^=]*=["][^"]*["])\\s*

Options:<br />
<pre><code class="lang-csharp">RegexOptions.IgnoreCase</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match a whitespace character atomically any number of times.

○ 1st capture group. ○ Match a character in the set [Xx]. ○ Match a character in the set [Mm]. ○ Match a character in the set [Ll]. ○ Match a character in the set [Nn]. ○ Match a character in the set [Ss]. ○ Match ':' greedily, optionally. ○ Match a character other than '=' atomically any number of times. ○ Match the string "="". ○ Match a character other than '"' atomically any number of times. ○ Match '"'. ○ Match a whitespace character atomically any number of times.

MatchXmlNamespacePrefixes()

[GeneratedRegex("\\s*xmlns:?([^=]*)=[\"][^\"]*[\"]\\s*", RegexOptions.IgnoreCase|RegexOptions.Multiline)]
public static Regex MatchXmlNamespacePrefixes()

Returns

Regex

Remarks

Pattern:

\\s*xmlns:?([^=]*)=["][^"]*["]\\s*

Options:<br />
<pre><code class="lang-csharp">RegexOptions.IgnoreCase | RegexOptions.Multiline</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match a whitespace character atomically any number of times.

○ Match a character in the set [Xx]. ○ Match a character in the set [Mm]. ○ Match a character in the set [Ll]. ○ Match a character in the set [Nn]. ○ Match a character in the set [Ss]. ○ Match ':' greedily, optionally. ○ 1st capture group. ○ Match a character other than '=' atomically any number of times. ○ Match the string "="". ○ Match a character other than '"' atomically any number of times. ○ Match '"'. ○ Match a whitespace character atomically any number of times.

MatchXmlNamespaceSchemaLocationAttributes()

[GeneratedRegex("\\s*([a-zA-z0-9:]*schemaLocation\\s*=[\"][^\"]*[\"])\\s*", RegexOptions.IgnoreCase)]
public static Regex MatchXmlNamespaceSchemaLocationAttributes()

Returns

Regex

Remarks

Pattern:

\\s*([a-zA-z0-9:]*schemaLocation\\s*=["][^"]*["])\\s*

Options:<br />
<pre><code class="lang-csharp">RegexOptions.IgnoreCase</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match a whitespace character atomically any number of times.

○ 1st capture group. ○ Match a character in the set [0-:A-z\u212A] greedily any number of times. ○ Match a character in the set [Ss]. ○ Match a character in the set [Cc]. ○ Match a character in the set [Hh]. ○ Match a character in the set [Ee]. ○ Match a character in the set [Mm]. ○ Match a character in the set [Aa]. ○ Match a character in the set [Ll]. ○ Match a character in the set [Oo]. ○ Match a character in the set [Cc]. ○ Match a character in the set [Aa]. ○ Match a character in the set [Tt]. ○ Match a character in the set [Ii]. ○ Match a character in the set [Oo]. ○ Match a character in the set [Nn]. ○ Match a whitespace character atomically any number of times. ○ Match the string "="". ○ Match a character other than '"' atomically any number of times. ○ Match '"'. ○ Match a whitespace character atomically any number of times.

MatchXmlNumericEntities()

[GeneratedRegex("\\&\\#\\d+\\;")]
public static Regex MatchXmlNumericEntities()

Returns

Regex

Remarks

Pattern:

\\&\\#\\d+\\;

Explanation:<br />
<pre><code class="lang-csharp">○ Match the string "&#".

○ Match a Unicode digit atomically at least once. ○ Match ';'.

OutputAs<TOut>(string)

Returns strongly typed output, converting the XML fragment.

[Obsolete("Use `ToOuterXmlString` and/or `ToXmlDocument` in `IXPathNavigableExtensions` with perhaps `XmlUtility.GetNavigableDocument` instead.")]
public static TOut? OutputAs<TOut>(string xmlFragment) where TOut : class

Parameters

xmlFragment string

An XML fragment or document as a well-formed string.

Returns

TOut

Returns the specified Type.

Type Parameters

TOut

The Type of output to return (constrained to class).

Remarks

This member only supports TIn as string, XmlDocument or XPathDocument.

OutputAs<TOut>(IXPathNavigable?)

Returns strongly typed output, converting the Navigable document.

[SuppressMessage("ReSharper", "PreferConcreteValueOverDefault")]
[Obsolete("Use `ToOuterXmlString` and/or `ToXmlDocument` in `IXPathNavigableExtensions` with perhaps `XmlUtility.GetNavigableDocument` instead.")]
public static TOut? OutputAs<TOut>(IXPathNavigable? navigableDocument) where TOut : class

Parameters

navigableDocument IXPathNavigable

An IXPathNavigable.

Returns

TOut

Returns the specified Type.

Type Parameters

TOut

The Type of output to return (constrained to class).

Remarks

This member only supports TIn as string, XmlDocument or XPathDocument.

StripNamespaces(string)

Strip the namespaces from specified string.

public static string? StripNamespaces(string xml)

Parameters

xml string

The source string.

Returns

string

Remarks

WARNING: Stripping namespaces “flattens” the document and can cause local-name collisions.

This routine does not remove namespace prefixes.

StripNamespaces(string?, bool)

Strip the namespaces from specified string.

public static string? StripNamespaces(string? xml, bool removeDocType)

Parameters

xml string

The source string.

removeDocType bool

When true, removes any DOCTYPE preambles.

Returns

string

Remarks

WARNING: Stripping namespaces “flattens” the document and can cause local-name collisions.

This routine does not remove namespace prefixes.

StripNamespaces(IXPathNavigable?)

Strip the namespaces from specified document.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? StripNamespaces(IXPathNavigable? navigable)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

Returns

XPathDocument

Remarks

WARNING: Stripping namespaces “flattens” the document and can cause local-name collisions.

This routine does not remove namespace prefixes.

StripNamespaces(IXPathNavigable?, bool)

Strip the namespaces from specified document.

[SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "Specific functionality provided by the concrete type may be required.")]
public static XPathDocument? StripNamespaces(IXPathNavigable? navigable, bool removeDocType)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

removeDocType bool

When true, removes any DOCTYPE preambles.

Returns

XPathDocument

Remarks

WARNING: Stripping namespaces “flattens” the document and can cause local-name collisions.

This routine does not remove namespace prefixes.

ValidateNavigableNode(IXPathNavigable?, XmlSchema?, ValidationEventHandler?)

Validates the specified navigable set with the specified schema and validation event handler.

public static void ValidateNavigableNode(IXPathNavigable? navigable, XmlSchema? schema, ValidationEventHandler? eventHandler)

Parameters

navigable IXPathNavigable

The source IXPathNavigable document.

schema XmlSchema

The XmlSchema.

eventHandler ValidationEventHandler

The ValidationEventHandler with signature MyHandler(object sender, ValidationEventArgs args).

WriteReader(XmlReader?, XmlWriter?)

Transfers the data in the Source to the Destination.

public static void WriteReader(XmlReader? readerSource, XmlWriter? writerDestination)

Parameters

readerSource XmlReader

The XmlReader.

writerDestination XmlWriter

The XmlWriter.

WriteXslTransform(IXPathNavigable?, IXPathNavigable?, string?)

Transforms the specified navigable documents and writes to disk with the specified path.

public static void WriteXslTransform(IXPathNavigable? xmlInput, IXPathNavigable? navigableXsl, string? outputPath)

Parameters

xmlInput IXPathNavigable

The specified input.

navigableXsl IXPathNavigable

The source IXPathNavigable document.

outputPath string

The file-system, target path.

WriteXslTransform(XmlReader?, IXPathNavigable?, string?)

Transforms the specified input and writes to disk.

public static void WriteXslTransform(XmlReader? xmlInput, IXPathNavigable? navigableXsl, string? outputPath)

Parameters

xmlInput XmlReader

The specified input.

navigableXsl IXPathNavigable

The source IXPathNavigable document.

outputPath string

The file-system, target path.

Write<T>(T?, string?)

Serializes and writes to the specified path.

public static void Write<T>(T? instance, string? path) where T : class

Parameters

instance T

The instance.

path string

The path.

Type Parameters

T

The type of the instance.

XmlDecode(string?)

Transforms selected HTML entities into their respective glyphs.

public static string? XmlDecode(string? value)

Parameters

value string

The value.

Returns

string
See Also

XmlEncode(string?)

Transforms selected XML glyphs into their respective HTML entities.

public static string? XmlEncode(string? value)

Parameters

value string

The value.

Returns

string

Remarks

This member will preserve HTML comments.

See Also