Class XmlUtility
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
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
parentDocumentIXPathNavigableThe IXPathNavigable “hosting” document.
childDocumentIXPathNavigableThe IXPathNavigable child document.
Returns
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
parentDocumentIXPathNavigableThe IXPathNavigable “hosting” document.
childDocumentIXPathNavigableThe IXPathNavigable child document.
nodeQuerystringThe XPath query to the child document location in the “hosting” document.
Returns
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
Returns
- T
Type Parameters
TThe 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
Returns
- T
Type Parameters
TThe specified type to deserialize.
GetInternalMessage(string)
Returns an XML string based on the specified header and lines.
public static string GetInternalMessage(string messageHeader)
Parameters
messageHeaderstringMessage header.
Returns
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
messageHeaderstringMessage header.
messageLinesReadOnlyCollection<string>Message lines.
Returns
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
messageHeaderstringMessage header.
messageCodestringMessage code for errors, exceptions or faults.
messageLinesIEnumerable<string>Message lines.
Returns
GetInternalMessage(string?, string?, string[]?, XmlWriter)
Gets the conventional, XML <InternalMessage>.
public static void GetInternalMessage(string? messageHeader, string? messageCode, string[]? messageLines, XmlWriter xmlDataWriter)
Parameters
messageHeaderstringMessage header.
messageCodestringMessage code for errors, exceptions or faults.
messageLinesstring[]Message lines.
xmlDataWriterXmlWriterThe 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
messageHeaderstringMessage header.
messageCodestringMessage code for errors, exceptions or faults.
messageLinesstring[]Message lines.
xmlDataWriterXmlWriterThe XmlWriter.
isFragmentboolWhen
falsea 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
Returns
GetInternalMessage(string?, string[]?, XmlWriter?)
Gets the conventional, XML <InternalMessage>.
public static void GetInternalMessage(string? messageHeader, string[]? messageLines, XmlWriter? xmlDataWriter)
Parameters
messageHeaderstringMessage header.
messageLinesstring[]Message lines.
xmlDataWriterXmlWriterThe XmlWriter.
GetInternalMessage(string?, string[]?, XmlWriter?, bool)
Gets the conventional, XML <InternalMessage>.
public static void GetInternalMessage(string? messageHeader, string[]? messageLines, XmlWriter? xmlDataWriter, bool isFragment)
Parameters
messageHeaderstringMessage header.
messageLinesstring[]Message lines.
xmlDataWriterXmlWriterThe XmlWriter.
isFragmentboolWhen
falsea 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
messageHeaderstringMessage header.
messageCodestringMessage code for errors, exceptions or faults
messageLinesstring[]Message lines.
Returns
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
Returns
GetNamespaceManager(IXPathNavigable?)
Returns a XmlNamespaceManager with respect to the document element of the specified IXPathNavigable document.
public static XmlNamespaceManager? GetNamespaceManager(IXPathNavigable? navigable)
Parameters
navigableIXPathNavigableThe IXPathNavigable document.
Returns
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
streamStreamThe stream.
Returns
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
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
nodeQuerystringThe value to be compiled into an XPathExpression.
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
nodeQuerystringThe value to be compiled into an XPathExpression.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
Returns
GetNavigableNodes(IXPathNavigable?, string?)
Returns an XPathNodeIterator based on the nodeQuery Expression toward the source document.
public static XPathNodeIterator? GetNavigableNodes(IXPathNavigable? navigable, string? nodeQuery)
Parameters
navigableIXPathNavigableThe source IXPathNavigable document.
nodeQuerystringThe value to be compiled into an XPathExpression.
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
nodeQuerystringThe value to be compiled into an XPathExpression.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.defaultValueobjectReturn the specified default value for “zero-length” text nodes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.defaultValueobjectReturn the specified default value for “zero-length” text nodes.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe XPath string.
throwExceptionboolWhen
true, throw an exception for null nodes and nodes that do not parse into the specified type.defaultValueTReturn a boxing object for “zero-length” text nodes.
Returns
Type Parameters
TThe 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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe XPath string.
throwExceptionboolWhen
true, throw an exception for null nodes and nodes that do not parse into the specified type.defaultValueTReturn a boxing object for “zero-length” text nodes.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
Returns
Type Parameters
TThe 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
navigableIXPathNavigableThe source IXPathNavigable document.
eventHandlerValidationEventHandlerThe ValidationEventHandler with signature MyHandler(object sender, ValidationEventArgs args).
Returns
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
navigableXslIXPathNavigableThe source IXPathNavigable XSL document.
navigableSetIXPathNavigableThe source IXPathNavigable XML document.
Returns
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
navigableXslIXPathNavigableThe source IXPathNavigable XSL document.
xslArgsXsltArgumentListThe XsltArgumentList.
navigableXmlIXPathNavigableThe source IXPathNavigable XML document.
Returns
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
navigableXslIXPathNavigableThe source IXPathNavigable XSL document.
navigableSetIXPathNavigableThe source IXPathNavigable XML document.
Returns
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
navigableXslIXPathNavigableThe source IXPathNavigable XSL document.
xslArgsXsltArgumentListThe XsltArgumentList.
navigableXmlIXPathNavigableThe source IXPathNavigable XML document.
Returns
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
navigableXslIXPathNavigableThe source IXPathNavigable XSL document.
xslArgsXsltArgumentListThe XsltArgumentList.
navigableXmlIXPathNavigableThe source IXPathNavigable XML document.
settingsXmlWriterSettingsThe settings.
Returns
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
inputTInThe input.
Returns
- XPathDocument
Returns an XPathDocument.
Type Parameters
TInThe 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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
testValuestringThe specified value to test with the node value.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
testValuestringThe specified value to test with the node value.
comparisonTypeStringComparisonThe StringComparison type.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
testValuestringThe specified value to test with the node value.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
Returns
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
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
testValuestringThe specified value to test with the node value.
nsManXmlNamespaceManagerThe XmlNamespaceManager to use to resolve prefixes.
comparisonTypeStringComparisonThe StringComparison type.
Returns
IsXml(string?)
Returns true when the fragment is XML-like.
public static bool IsXml(string? fragment)
Parameters
fragmentstringThe fragment to test.
Returns
IsYesNodeValue(IXPathNavigable?, string?, bool)
Returns true when the node has the value “yes”.
public static bool IsYesNodeValue(IXPathNavigable? node, string? nodeQuery, bool throwException)
Parameters
nodeIXPathNavigableThe IXPathNavigable node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
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
pathToSchemastringThe valid path to an XML Schema file.
eventHandlerValidationEventHandlerThe ValidationEventHandler with signature MyHandler(object sender, ValidationEventArgs args).
Returns
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
Returns
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
xslPathstringOutput path to the XSLT file.
commandNamestringThe value for thecmd-parameter convention.
xmlPathstringOutput path to the XML file.
Returns
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
xslPathstringOutput path to the XSLT file.
xslArgsXsltArgumentListThe XsltArgumentList.
xmlPathstringOutput path to the XML file.
Returns
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
xslPathstringOutput path to the XSLT file.
commandNamestringThe value for thecmd-parameter convention.
xmlFragmentstringA well-formed XML string.
Returns
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
xslPathstringOutput path to the XSLT file.
commandNamestringThe value for thecmd-parameter convention.
navigableXmlIXPathNavigableThe IXPathNavigable in memory.
Returns
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
xslPathstringOutput path to the XSLT file.
xslArgsXsltArgumentListThe XsltArgumentList.
xmlFragmentstringA well-formed XML string.
Returns
Remarks
This convention is used in ASP.NET Web applications.
MatchAllThatLooksLikeXmlMarkup()
[GeneratedRegex("<\\s*([^>]+)\\s*>")]
public static Regex MatchAllThatLooksLikeXmlMarkup()
Returns
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
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
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
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
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
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
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
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
Returns
- TOut
Returns the specified Type.
Type Parameters
TOutThe 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
navigableDocumentIXPathNavigableAn IXPathNavigable.
Returns
- TOut
Returns the specified Type.
Type Parameters
TOutThe 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
Returns
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
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
removeDocTypeboolWhen
true, removes any DOCTYPE preambles.
Returns
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
navigableIXPathNavigableThe source IXPathNavigable document.
schemaXmlSchemaThe XmlSchema.
eventHandlerValidationEventHandlerThe 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
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
xmlInputIXPathNavigableThe specified input.
navigableXslIXPathNavigableThe source IXPathNavigable document.
outputPathstringThe 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
xmlInputXmlReaderThe specified input.
navigableXslIXPathNavigableThe source IXPathNavigable document.
outputPathstringThe 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
instanceTThe instance.
pathstringThe path.
Type Parameters
TThe type of the instance.
XmlDecode(string?)
Transforms selected HTML entities into their respective glyphs.
public static string? XmlDecode(string? value)
Parameters
valuestringThe value.
Returns
- See Also
XmlEncode(string?)
Transforms selected XML glyphs into their respective HTML entities.
public static string? XmlEncode(string? value)
Parameters
valuestringThe value.
Returns
Remarks
This member will preserve HTML comments.
- See Also