System.Xml.XmlDocument.AppendChildForLoad C# (CSharp) Method

AppendChildForLoad() private method

private AppendChildForLoad ( XmlNode newChild, XmlDocument doc ) : XmlNode
newChild XmlNode
doc XmlDocument
return XmlNode
        internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc)
        {
            Debug.Assert(doc == this);

            if (!IsValidChildType(newChild.NodeType))
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);

            if (!CanInsertAfter(newChild, LastChild))
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);

            XmlNodeChangedEventArgs args = GetInsertEventArgsForLoad(newChild, this);

            if (args != null)
                BeforeEvent(args);

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (_lastChild == null)
            {
                newNode.next = newNode;
            }
            else
            {
                newNode.next = _lastChild.next;
                _lastChild.next = newNode;
            }

            _lastChild = newNode;
            newNode.SetParentForLoad(this);

            if (args != null)
                AfterEvent(args);

            return newNode;
        }

Usage Example

Example #1
0
 //The function will start loading the document from where current XmlReader is pointing at.
 private void LoadDocSequence( XmlDocument parentDoc ) {
     Debug.Assert( this.reader != null );
     Debug.Assert( parentDoc != null );
     XmlNode node = null;
     while ( ( node = LoadCurrentNode() ) != null ) {
         parentDoc.AppendChildForLoad( node, parentDoc );
         if ( !this.reader.Read() )
             return;
     }
 }
All Usage Examples Of System.Xml.XmlDocument::AppendChildForLoad