diff --git a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs index d5dd184..a017e53 100644 --- a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs +++ b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs @@ -114,6 +114,22 @@ namespace ICD.Common.Utils.Xml return bool.Parse(value); } + /// + /// Gets the value of the attribute with the given name and returns as a GUID. + /// + /// + /// + /// + [PublicAPI] + public static Guid GetAttributeAsGuid(this IcdXmlReader extends, string name) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + string value = extends.GetAttributeAsString(name); + return new Guid(value); + } + #endregion #region Recurse diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index 676195e..2d26022 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -145,6 +145,22 @@ namespace ICD.Common.Utils.Xml } } + /// + /// Gets the value of the attribute with the given name and returns as a GUID. + /// + /// + /// + /// + [PublicAPI] + public static Guid GetAttributeAsGuid(string xml, string name) + { + using (IcdXmlReader reader = new IcdXmlReader(xml)) + { + reader.ReadToNextElement(); + return reader.GetAttributeAsGuid(name); + } + } + /// /// Gets the value of the attribute with the given name and returns as a bool. ///