示例#1
0
 /// <summary>
 /// Append content at the end of the element
 /// </summary>
 public static HElement Append(this HElement element, params object[] content)
 {
     if (element != null)
     {
         element.Add(content);
     }
     return(element);
 }
示例#2
0
 /// <summary>
 /// Set one attribute for the element.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="name">Attribute name.</param>
 /// <param name="value">Attribute value</param>
 /// <returns>The element</returns>
 public static HElement Attribute(this HElement element, String name, String value)
 {
     if (element != null && !String.IsNullOrWhiteSpace(name))
     {
         var attr = element.Attribute(name);
         if (String.IsNullOrEmpty(value))
         {
             if (attr != null)
             {
                 attr.Remove();
             }
         }
         else
         {
             if (attr == null)
             {
                 attr = new HAttribute(name);
                 element.Add(attr);
             }
             attr.Value = value;
         }
     }
     return(element);
 }