using System; using System.Collections.Generic; using System.Xml; //+ namespace General.Xml { public static class XmlSimpleExtractor { //- @ExtractBranch -// public static List ExtractBranch(XmlNode mailRoot, String branchName, Boolean required) { List list = new List(); XmlNode result = mailRoot.SelectSingleNode(branchName); if (result != null && result.HasChildNodes) { foreach (XmlNode node in result.ChildNodes) { list.Add(node.InnerText); } } else { if (required) { throw new XmlException(String.Format("Missing element '{0}'", branchName)); } } //+ return list; } //- @ExtractText -// public static String ExtractText(XmlNode mailRoot, String nodeName) { XmlNode result = mailRoot.SelectSingleNode(nodeName); if (result != null) { return result.InnerText; } else { throw new XmlException(String.Format("Missing element '{0}'", nodeName)); } } } }