Exemple #1
0
        //
        // Summary:
        //     When overridden in a derived class, closes one element and pops the corresponding
        //     namespace scope.
        //
        // Exceptions:
        //   System.InvalidOperationException:
        //     This results in an invalid XML document.
        public void WriteEndElement()
        {
            // Check to see if a started attribute need finished
            if (_WriteState == WriteState.Attribute)
            {
                this.WriteEndAttribute();
            }

            // Pop the last Element from the stack
            ElementInfo lastElement = _ElementStack.Pop();

            // Check to see if content was been writen. If so use full end tag else use shorthand
            if (lastElement.IsEmpty == false)
            {
                if (lastElement.NSPrefix == null || lastElement.NSPrefix == "")
                {
                    this.WriteRaw("</" + lastElement.Name + ">");
                }
                else
                {
                    this.WriteRaw("</" + lastElement.NSPrefix + ":" + lastElement.Name + ">");
                }
            }
            else if (lastElement.State == WriteState.Element)
            {
                this.WriteRaw("/>");
            }
            else
            {
                throw new InvalidOperationException("An EndElement would create malformer XML");
            }
        }