AGS.Types.SerializeUtils.GetElementString C# (CSharp) Méthode

GetElementString() public static méthode

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
Résultat 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

Exemple #1
0
 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