Append() публичный Метод

public Append ( XmlAttribute node ) : XmlAttribute
node XmlAttribute
Результат XmlAttribute
Пример #1
0
        static void SortXmlAttributeCollection( XmlAttributeCollection col )
        {
            // Remove, sort, then re-add the attributes to the collection.
            if (sort_attr && col != null && col.Count > 0) {
                List<XmlAttribute> attrs = new List<XmlAttribute>(col.Count);

                for (int i = col.Count - 1; i >= 0; i--) {
                    attrs.Add(col[i]);
                    col.RemoveAt(i);
                }

                SortAttributeList(attrs);

                for (int i = 0; i < attrs.Count; i++) {
                    col.Append(attrs[i]);
                }
            }
        }
Пример #2
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes,
        // becaouse we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, becaouse
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r      = this.reader;
            XmlNode   parent = null;

            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    bool       fEmptyElement = reader.IsEmptyElement;
                    XmlElement element       = new XmlElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    element.IsEmpty = fEmptyElement;

                    if (reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        do
                        {
                            XmlAttribute attr = LoadAttributeNodeDirect();
                            attributes.Append(attr);     // special case for load
                        } while (r.MoveToNextAttribute());
                    }

                    // recursively load all children.
                    if (!fEmptyElement)
                    {
                        parent.AppendChildForLoad(element, doc);
                        parent = element;
                        continue;
                    }
                    else
                    {
                        node = element;
                        break;
                    }

                case XmlNodeType.EndElement:
                    Debug.Assert(parent.NodeType == XmlNodeType.Element);
                    if (parent.ParentNode == null)
                    {
                        return(parent);
                    }
                    parent = parent.ParentNode;
                    continue;

                case XmlNodeType.EntityReference:
                    node = LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.EndEntity:
                    continue;

                case XmlNodeType.Attribute:
                    node = LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace(reader.Value, this.doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (preserveWhitespace)
                    {
                        node = new XmlWhitespace(reader.Value, this.doc);
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText(reader.Value, this.doc);
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection(reader.Value, this.doc);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction(reader.Name, reader.Value, this.doc);
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment(reader.Value, this.doc);
                    break;

                default:
                    throw UnexpectedNodeType(reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, doc);
                }
                else
                {
                    return(node);
                }
            }while (r.Read());

            return(null);
        }