Microsoft.Protocols.TestSuites.MS_LISTSWS.S03_OperationOnListItem.IgnoreAttributeExcept C# (CSharp) Method

IgnoreAttributeExcept() private static method

This method is used to set attribute value as NULL from an xml element, except the specified attribute names.
private static IgnoreAttributeExcept ( XmlElement row ) : void
row System.Xml.XmlElement The specified xml element instance.
return void
        private static void IgnoreAttributeExcept(XmlElement row, params string[] attrNames)
        {
            // Only interested in the element that is called z:row.
            if (row.LocalName != "row")
            {
                return;
            }

            int i = 0;
            while (i < row.Attributes.Count)
            {
                bool isFind = false;
                XmlAttribute attr = row.Attributes[i];
                foreach (string fieldName in attrNames)
                {
                    if (attr.LocalName == string.Format("{0}{1}", AdapterHelper.PrefixOws, fieldName))
                    {
                        i++;
                        isFind = true;
                        break;
                    }
                }

                if (!isFind)
                {
                    row.Attributes.Remove(attr);
                }
            }
        }
S03_OperationOnListItem