System.Xml.DocumentXPathNavigator.SetValue C# (CSharp) Method

SetValue() public method

public SetValue ( string value ) : void
value string
return void
        public override void SetValue(string value) {
            if (value == null) {
                throw new ArgumentNullException("value");
            }

            XmlNode node = source;
            XmlNode end;

            switch (node.NodeType) {
                case XmlNodeType.Attribute:
                    if (((XmlAttribute)node).IsNamespace) {
                        goto default;
                    }
                    node.InnerText = value;
                    break;
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    CalibrateText();

                    node = source;
                    end = TextEnd(node);
                    if (node != end) {
                        if (node.IsReadOnly) {
                            throw new InvalidOperationException(Res.GetString(Res.Xdom_Node_Modify_ReadOnly));
                        }
                        DeleteToFollowingSibling(node.NextSibling, end);
                    }
                    goto case XmlNodeType.Element;
                case XmlNodeType.Element:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.Comment:
                    node.InnerText = value;
                    break;
                default:
                    throw new InvalidOperationException(Res.GetString(Res.Xpn_BadPosition));
            }
        }