Class XObjectUtility
Static helper members for XML-related routines.
public static class XObjectUtility
- Inheritance
-
XObjectUtility
- Inherited Members
Remarks
These definitions are biased toward emitting XPathDocument documents. However, many accept any input implementing the IXPathNavigable interface.
Fields
GlyphNonBreakingSpace
Glyph: Non-Breaking Space
public const string GlyphNonBreakingSpace = " "
Field Value
Properties
XTextNonBreakingSpace
XText: Non-Breaking Space
public static XText XTextNonBreakingSpace { get; }
Property Value
Methods
GetCDataValue(XElement?)
Get the CDATA value from the specified XElement.
public static string? GetCDataValue(XElement? element)
Parameters
Returns
GetCDataValue(XNode?)
Get the CDATA value from the specified XNode.
public static string? GetCDataValue(XNode? node)
Parameters
Returns
GetLocalNameXPathQuery(string?)
Gets the XNode into a local-name(), XPath-predicate query.
public static string? GetLocalNameXPathQuery(string? childElementName)
Parameters
childElementNamestringName of the child element.
Returns
GetLocalNameXPathQuery(string?, string?)
Gets the XNode into a local-name(), XPath-predicate query.
public static string? GetLocalNameXPathQuery(string? namespacePrefixOrUri, string? childElementName)
Parameters
namespacePrefixOrUristringThe namespace prefix or URI.
childElementNamestringName of the child element.
Returns
GetLocalNameXPathQuery(string?, string?, string?)
Gets the XNode into a local-name(), XPath-predicate query.
public static string? GetLocalNameXPathQuery(string? namespacePrefixOrUri, string? childElementName, string? childAttributeName)
Parameters
namespacePrefixOrUristringThe namespace prefix or URI.
childElementNamestringName of the child element.
childAttributeNamestringName of the child attribute.
Returns
Remarks
This routine is useful when namespace-resolving is not desirable or available.
GetValue(XNode?, string?)
Gets the element or attribute value of the specified element.
public static string? GetValue(XNode? currentNode, string? query)
Parameters
Returns
GetValue(XNode?, string?, bool)
Gets the element or attribute value of the current element.
public static string? GetValue(XNode? currentNode, string? query, bool throwException)
Parameters
currentNodeXNodeThe current XNode.
querystringThe xpath query.
throwExceptionboolif set to
truethrow exception.
Returns
GetXAttributeValue(XNode?, string?, bool)
Returns an object for parsing and adding to a list of parameters for data access.
public static string? GetXAttributeValue(XNode? node, string? nodeQuery, bool throwException)
Parameters
nodeXNodeThe XNode.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
GetXAttributeValue(XNode?, string?, bool, string?)
Returns an object for parsing and adding to a list of parameters for data access.
public static string? GetXAttributeValue(XNode? node, string? nodeQuery, bool throwException, string? defaultValue)
Parameters
nodeXNodeThe XNode.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
defaultValuestringReturn the specified default value for “zero-length” text nodes.
Returns
GetXAttributeValue(XNode?, string?, bool, string?, IXmlNamespaceResolver?)
Returns an object for parsing and adding to a list of parameters for data access.
public static string? GetXAttributeValue(XNode? node, string? nodeQuery, bool throwException, string? defaultValue, IXmlNamespaceResolver? resolver)
Parameters
nodeXNodeThe XNode.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
defaultValuestringReturn the specified default value for “zero-length” text nodes.
resolverIXmlNamespaceResolverThe IXmlNamespaceResolver to use to resolve prefixes.
Returns
GetXAttributeValueAndParse<T>(XNode?, string?, bool, T)
Returns an object for parsing and adding to a list of parameters for data access.
public static object? GetXAttributeValueAndParse<T>(XNode? node, string? nodeQuery, bool throwException, T defaultValue)
Parameters
nodeXNodeThe XNode.
nodeQuerystringThe XPath string.
throwExceptionboolWhentrue, 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.
GetXAttributeValueAndParse<T>(XNode?, string?, bool, T?, IXmlNamespaceResolver?)
Returns an object for parsing and adding to a list of parameters for data access.
public static object? GetXAttributeValueAndParse<T>(XNode? node, string? nodeQuery, bool throwException, T? defaultValue, IXmlNamespaceResolver? resolver)
Parameters
nodeXNodeThe XNode.
nodeQuerystringThe XPath string.
throwExceptionboolWhentrue, 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.
resolverIXmlNamespaceResolverThe IXmlNamespaceResolver to use to resolve prefixes.
Returns
Type Parameters
TThe type to parse from the node value.
GetXDeclaration()
Gets the XDeclaration.
public static XDeclaration GetXDeclaration()
Returns
GetXDeclaration(string?, bool)
Gets the XDeclaration.
public static XDeclaration GetXDeclaration(string? encoding, bool isStandAlone)
Parameters
encodingstringThe encoding (Utf08 by default).
isStandAloneboolWhen
truedocument is stand-alone (trueby default).
Returns
GetXElement(string?, object?)
Gets the XElement.
public static XElement GetXElement(string? rootElement, object? innerXml)
Parameters
Returns
GetXElement(XNode?, string?)
Gets the XElement.
public static XElement? GetXElement(XNode? root, string? pathToElement)
Parameters
Returns
GetXElements(XNode?, string?)
Gets the IEnumerable<T>.
public static IEnumerable<XElement> GetXElements(XNode? currentElement, string? query)
Parameters
Returns
GetXNode(XNode?, string?)
Gets the XNode from the specified XPath query.
public static XNode? GetXNode(XNode? node, string? nodeQuery)
Parameters
Returns
GetXNode(XNode?, string?, bool)
Gets the XNode from the specified XPath query.
public static XNode? GetXNode(XNode? node, string? nodeQuery, bool throwException)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
GetXNode(XNode?, string?, bool, IXmlNamespaceResolver)
Gets the XNode from the specified XPath query.
public static XNode? GetXNode(XNode? node, string? nodeQuery, bool throwException, IXmlNamespaceResolver resolver)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
resolverIXmlNamespaceResolverThe resolver.
Returns
GetXNodes(XNode?, string?)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XNode> GetXNodes(XNode? node, string? nodeQuery)
Parameters
Returns
GetXNodes(XNode?, string?, bool)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XNode> GetXNodes(XNode? node, string? nodeQuery, bool throwException)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
GetXNodes(XNode?, string?, bool, IXmlNamespaceResolver?)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XNode> GetXNodes(XNode? node, string? nodeQuery, bool throwException, IXmlNamespaceResolver? resolver)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
resolverIXmlNamespaceResolverThe resolver.
Returns
GetXObject(XNode?, string?)
Gets the XObject from the specified XPath query.
public static XObject? GetXObject(XNode? node, string? nodeQuery)
Parameters
Returns
GetXObject(XNode?, string?, bool)
Gets the XObject from the specified XPath query.
public static XObject? GetXObject(XNode? node, string? nodeQuery, bool throwException)
Parameters
nodeXNodeThe XNode node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
GetXObject(XNode?, string?, bool, IXmlNamespaceResolver?)
Gets the XObject.
public static XObject? GetXObject(XNode? node, string? nodeQuery, bool throwException, IXmlNamespaceResolver? resolver)
Parameters
nodeXNodeThe XNode node.
nodeQuerystringThe node query string.
throwExceptionboolWhen
true, throw an exception for null nodes.
resolverIXmlNamespaceResolverThe IXmlNamespaceResolver to use to resolve prefixes.
Returns
GetXObjects(XNode?, string?)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XObject> GetXObjects(XNode? node, string? nodeQuery)
Parameters
Returns
GetXObjects(XNode?, string?, bool)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XObject> GetXObjects(XNode? node, string? nodeQuery, bool throwException)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
Returns
GetXObjects(XNode?, string?, bool, IXmlNamespaceResolver?)
Gets IEnumerable<T> from the specified XPath query.
public static IEnumerable<XObject> GetXObjects(XNode? node, string? nodeQuery, bool throwException, IXmlNamespaceResolver? resolver)
Parameters
nodeXNodeThe node.
nodeQuerystringThe node query.
throwExceptionboolWhen
true, throw an exception for null nodes.
resolverIXmlNamespaceResolverThe resolver.
Returns
JoinFlattenedXTextNodes(XElement?)
Joins the flattened XText nodes.
public static string? JoinFlattenedXTextNodes(XElement? rootElement)
Parameters
rootElementXElementThe root element.
Returns
JoinFlattenedXTextNodes(XElement?, bool)
Joins the flattened XText nodes.
public static string? JoinFlattenedXTextNodes(XElement? rootElement, bool includeRootElement)
Parameters
Returns
JoinFlattenedXTextNodes(XElement?, bool, string?)
Joins the flattened XText nodes.
public static string? JoinFlattenedXTextNodes(XElement? rootElement, bool includeRootElement, string? joinDelimiter)
Parameters
rootElementXElementThe root element.
includeRootElementboolWhen
trueinclude root element.joinDelimiterstringThe join delimiter.