AGS.Types.SerializeUtils.GetElementString C# (CSharp) Method

GetElementString() public static method

Wrapper function for SelectSingleNode that throws an exception mentioning the node name if it is not found. Returns the node text if successful.
public static GetElementString ( XmlNode node, string elementName ) : string
node System.Xml.XmlNode
elementName string
return string
        public static string GetElementString(XmlNode node, string elementName)
        {
            XmlNode foundNode = node.SelectSingleNode(elementName);
            if (foundNode == null)
            {
                throw new InvalidDataException("Missing XML element: " + elementName);
            }
            return foundNode.InnerText;
        }

Usage Example

Esempio n. 1
0
File: View.cs Progetto: stee01/ags
 public View(XmlNode node)
 {
     ID   = Convert.ToInt32(SerializeUtils.GetElementString(node, "ID"));
     Name = SerializeUtils.GetElementString(node, "Name");
     foreach (XmlNode loopNode in SerializeUtils.GetChildNodes(node, "Loops"))
     {
         _loops.Add(new ViewLoop(loopNode));
     }
 }
All Usage Examples Of AGS.Types.SerializeUtils::GetElementString