first commit
This commit is contained in:
30
HelpersXml/XmlHelper.cs
Normal file
30
HelpersXml/XmlHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace EFCDesk.HelpersXml
|
||||
{
|
||||
public static class XmlHelper
|
||||
{
|
||||
public static string Value(XElement? parent, XName elementName)
|
||||
=> parent?.Element(elementName)?.Value?.Trim() ?? string.Empty;
|
||||
|
||||
public static string Value(XElement? parent, string elementName)
|
||||
=> parent?.Element(elementName)?.Value?.Trim() ?? string.Empty;
|
||||
|
||||
public static decimal? Decimal(XElement parent, XName elementName)
|
||||
{
|
||||
var value = Value(parent, elementName);
|
||||
if (decimal.TryParse(value, out var result))
|
||||
return result;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<XElement> Elements(XElement? parent, XName elementName)
|
||||
=> parent?.Elements(elementName)?.ToList() ?? new List<XElement>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user