/// <summary> /// Updates the attribute with name key of element el. /// </summary> /// <param name='el'> /// the tag's XElement instance /// </param> /// <param name='key'> /// Key. /// </param> /// <param name='value'> /// The new value of the attribute /// </param> public void UpdateAttribute(XElement el, string key, string value) { UpdateAttribute( XDocumentHelper.GetAttributeCI(el.Attributes, key), value ); }
/// <summary> /// Sets an attribtue value in the source code editor to the provided value string. /// </summary> /// <param name='el'> /// the tag's XElement instance /// </param> /// <param name='key'> /// Name of the attribute /// </param> /// <param name='value'> /// The string of the new value. /// </param> public void SetAttribtue(XElement el, string key, string value) { XAttribute attr = XDocumentHelper.GetAttributeCI(el.Attributes, key); if (attr == null) { InsertAttribute(el, key, value); } else if (attr.Value != value) { UpdateAttribute(attr, value); } }
/// <summary> /// Removes an attribute with name "key" from XElement "el" in the source code editor /// </summary> /// <param name='el'> /// the tag's XElement instance /// </param> /// <param name='key'> /// Name of the attribute /// </param> public void RemoveAttribute(XElement el, string key) { document.RemoveText( XDocumentHelper.GetAttributeCI(el.Attributes, key).Region ); }