コード例 #1
0
        /// <include file='doc\XmlElement.uex' path='docs/doc[@for="XmlElement.CloneNode"]/*' />
        /// <devdoc>
        ///    <para>Creates a duplicate of this node.</para>
        /// </devdoc>
        public override XmlNode CloneNode(bool deep)
        {
            Debug.Assert(OwnerDocument != null);
            bool OrigLoadingStatus = OwnerDocument.IsLoading;

            OwnerDocument.IsLoading = true;
            XmlElement element = OwnerDocument.CreateElement(Prefix, LocalName, NamespaceURI);

            if (element.IsEmpty != IsEmpty)
            {
                element.IsEmpty = this.IsEmpty;
            }
            OwnerDocument.IsLoading = OrigLoadingStatus;

            if (HasAttributes)
            {
                foreach (XmlAttribute attr in Attributes)
                {
                    XmlAttribute newAttr = (XmlAttribute)(attr.CloneNode(true));
                    if (attr is XmlUnspecifiedAttribute && attr.Specified == false)
                    {
                        (( XmlUnspecifiedAttribute )newAttr).SetSpecified(false);
                    }
                    element.Attributes.Append(newAttr);
                }
            }
            if (deep)
            {
                element.CopyChildren(this, deep);
            }

            return(element);
        }
コード例 #2
0
        // Creates a duplicate of this node.
        public override XmlNode CloneNode(bool deep)
        {
            Debug.Assert(OwnerDocument != null);
            XmlDocument doc = OwnerDocument;
            bool        OrigLoadingStatus = doc.IsLoading;

            doc.IsLoading = true;
            XmlElement element = doc.CreateElement(Prefix, LocalName, NamespaceURI);

            doc.IsLoading = OrigLoadingStatus;
            if (element.IsEmpty != this.IsEmpty)
            {
                element.IsEmpty = this.IsEmpty;
            }

            if (HasAttributes)
            {
                foreach (XmlAttribute attr in Attributes)
                {
                    XmlAttribute            newAttr    = (XmlAttribute)(attr.CloneNode(true));
                    XmlUnspecifiedAttribute unspecAttr = newAttr as XmlUnspecifiedAttribute;
                    if (unspecAttr != null && attr.Specified == false)
                    {
                        unspecAttr.SetSpecified(false);
                    }
                    element.Attributes.InternalAppendAttribute(newAttr);
                }
            }
            if (deep)
            {
                element.CopyChildren(doc, this, deep);
            }

            return(element);
        }
コード例 #3
0
        public override XmlNode CloneNode(bool deep)
        {
            XmlDocument ownerDocument = this.OwnerDocument;
            bool        isLoading     = ownerDocument.IsLoading;

            ownerDocument.IsLoading = true;
            XmlElement element = ownerDocument.CreateElement(this.Prefix, this.LocalName, this.NamespaceURI);

            ownerDocument.IsLoading = isLoading;
            if (element.IsEmpty != this.IsEmpty)
            {
                element.IsEmpty = this.IsEmpty;
            }
            if (this.HasAttributes)
            {
                foreach (XmlAttribute attribute in this.Attributes)
                {
                    XmlAttribute node = (XmlAttribute)attribute.CloneNode(true);
                    if ((attribute is XmlUnspecifiedAttribute) && !attribute.Specified)
                    {
                        ((XmlUnspecifiedAttribute)node).SetSpecified(false);
                    }
                    element.Attributes.InternalAppendAttribute(node);
                }
            }
            if (deep)
            {
                element.CopyChildren(ownerDocument, this, deep);
            }
            return(element);
        }