35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using System.Xml;
|
|
using System.Xml.Linq;
|
|
using System.Xml.XPath;
|
|
|
|
namespace CRIF.ACTion.Common.Parsers
|
|
{
|
|
public static class XElementExtensions
|
|
{
|
|
/*
|
|
Using XPathSelectElement on an XElement starts with the XElement's parent XDocument,
|
|
unless you convert the XElement itself to an XDocument
|
|
*/
|
|
|
|
public static XElement XElementXPathSelectElement(this XElement node, string expression)
|
|
{
|
|
return (new XDocument(node)).XPathSelectElement(expression);
|
|
}
|
|
|
|
public static XElement XElementXPathSelectElement(this XNode node, string expression, IXmlNamespaceResolver resolver)
|
|
{
|
|
return (new XDocument(node)).XPathSelectElement(expression, resolver);
|
|
}
|
|
|
|
public static IEnumerable<XElement> XElementXPathSelectElements(this XElement node, string expression)
|
|
{
|
|
return (new XDocument(node)).XPathSelectElements(expression);
|
|
}
|
|
|
|
public static IEnumerable<XElement> XElementXPathSelectElements(this XElement node, string expression, IXmlNamespaceResolver resolver)
|
|
{
|
|
return (new XDocument(node)).XPathSelectElements(expression, resolver);
|
|
}
|
|
}
|
|
}
|