/// <summary>Sets the <see cref="AtomTextNode.Text"/> of this node, and sets the <see cref="AtomTextNode.Type"/> of this node to <see cref="AtomTextType.Text"/>.</summary>
    /// <param name="text">A <see cref="string"/> representing the text to set.</param>
    /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
    /// <exception cref="ArgumentNullException"><paramref name="text"/> is null.</exception>
    /// <exception cref="ArgumentException"><paramref name="text"/> is an empty <see cref="string"/>, or <paramref name="type"/> is "xhtml" and <paramref name="text"/> is not a valid XHTML element.</exception>
    /// <exception cref="InvalidOperationException"><paramref name="type"/> is "xhtml" and <paramref name="text"/> is not a valid XHTML div element.</exception>
    public void SetText(string text, AtomTextType type)
    {
      if(text == null) throw new ArgumentNullException("text");
      if(text == "") throw new ArgumentException(Errors.EmptyString, "text");

      if(type == AtomTextType.Xhtml)
      {
        XElement div = null;
        try { div = XElement.Parse(text); }
        catch(Exception) { throw new ArgumentException(Errors.NotAnElement, "text"); }
        if(div.Name != XhtmlNamespace + "div") throw new InvalidOperationException(Errors.NotAnXhtmlDiv);
        this.Element.ReplaceNodes(div);
      }
      else
        this.Element.SetValue(text);

      this.Element.SetAttributeValue("type", type == AtomTextType.None ? null : type.ToString().ToLower());
    }