HandCoded.Xml.NodeIndex.GetElementById C# (CSharp) Method

GetElementById() public method

Returns the XmlElement in the indexed document that has an id attribute with the given value.
public GetElementById ( string id ) : XmlElement
id string The required id attribute value.
return System.Xml.XmlElement
        public XmlElement GetElementById(string id)
        {
            return (elementsById.ContainsKey (id) ? elementsById [id] : null);
        }

Usage Example

        private static bool Rule01(string name, NodeIndex nodeIndex, XmlNodeList list,
            ValidationErrorHandler errorHandler)
        {
            bool		result 	= true;

            foreach (XmlElement	 context in list) {
                XmlElement		generic	= XPath.Path (context, "generic");
                XmlAttribute	href;
                XmlElement		target;

                if ((generic == null) ||
                    ((href = generic.GetAttributeNode ("href")) == null) ||
                    ((target = nodeIndex.GetElementById (href.Value)) == null)) continue;

                string targetName = target.LocalName;

                if (targetName.Equals ("basket") ||
                    targetName.Equals ("cash") ||
                    targetName.Equals ("commodity") ||
                    targetName.Equals ("deposit") ||
                    targetName.Equals ("bond") ||
                    targetName.Equals ("convertibleBond") ||
                    targetName.Equals ("equity") ||
                    targetName.Equals ("exchangeTradedFund") ||
                    targetName.Equals ("index") ||
                    targetName.Equals ("future") ||
                    targetName.Equals ("fxRate") ||
                    targetName.Equals ("loan") ||
                    targetName.Equals ("mortgage") ||
                    targetName.Equals ("mutualFund") ||
                    targetName.Equals ("rateIndex") ||
                    targetName.Equals ("simpleCreditDefautSwap") ||
                    targetName.Equals ("simpleFra") ||
                    targetName.Equals ("simpleIrSwap") ||
                    targetName.Equals ("dealSummary") ||
                    targetName.Equals ("facilitySummary")) continue;

                errorHandler ("305", context,
                    "generic/@href must match the @id attribute of an element of type Asset",
                    name, targetName);

                result = false;
            }
            return (result);
        }
All Usage Examples Of HandCoded.Xml.NodeIndex::GetElementById