2014-11-24 23:16:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.Extensions
|
|
|
|
|
{
|
2017-03-05 07:50:45 +00:00
|
|
|
|
public static class XmlExtensions
|
2014-11-24 23:16:29 +00:00
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<XElement> FindDecendants(this XContainer container, string localName)
|
|
|
|
|
{
|
|
|
|
|
return container.Descendants().Where(c => c.Name.LocalName.Equals(localName, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
|
}
|
2020-04-16 20:16:50 +00:00
|
|
|
|
|
|
|
|
|
public static bool TryGetAttributeValue(this XElement element, string name, out string value)
|
|
|
|
|
{
|
|
|
|
|
var attr = element.Attribute(name);
|
|
|
|
|
|
|
|
|
|
if (attr != null)
|
|
|
|
|
{
|
|
|
|
|
value = attr.Value;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = null;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-24 23:16:29 +00:00
|
|
|
|
}
|
2017-03-05 07:50:45 +00:00
|
|
|
|
}
|