InsertBefore() public method

public InsertBefore ( ) : XmlWriter
return System.Xml.XmlWriter
Esempio n. 1
0
        public virtual XmlWriter PrependChild()
        {
            XPathNavigator nav = Clone();

            if (nav.MoveToFirstChild())
            {
                return(nav.InsertBefore());
            }
            else
            {
                return(AppendChild());
            }
        }
Esempio n. 2
0
        public virtual XmlWriter InsertAfter()
        {
            switch (NodeType)
            {
            case XPathNodeType.Root:
            case XPathNodeType.Attribute:
            case XPathNodeType.Namespace:
                throw new InvalidOperationException(String.Format("Insertion after {0} is not allowed.", NodeType));
            }
            XPathNavigator nav = Clone();

            if (nav.MoveToNext())
            {
                return(nav.InsertBefore());
            }
            else if (nav.MoveToParent())
            {
                return(nav.AppendChild());
            }
            else
            {
                throw new InvalidOperationException("Could not move to parent to insert sibling node");
            }
        }