System.Xml.XmlReader.ReadAttributeValue C# (CSharp) Method

ReadAttributeValue() public abstract method

public abstract ReadAttributeValue ( ) : bool
return bool
        public abstract bool ReadAttributeValue();

Usage Example

Example #1
0
        // Write the attributes at the current position of an XmlReader.
        public virtual void WriteAttributes(XmlReader reader, bool defattr)
        {
            // Validate the parameters.
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // Determine if we are on an element/xmldecl node or
            // on an attribute.  If we are on an element/xmldecl,
            // then we need to reset at the end of the output.
            XmlNodeType type = reader.NodeType;
            bool        reset;

            if (type == XmlNodeType.Element ||
                type == XmlNodeType.XmlDeclaration)
            {
                if (!reader.MoveToFirstAttribute())
                {
                    return;
                }
                reset = true;
            }
            else if (type != XmlNodeType.Attribute)
            {
                throw new XmlException(S._("Xml_IncorrectNode"));
            }
            else
            {
                reset = false;
            }

            // Output the attributes in order.
            do
            {
                if (defattr || !(reader.IsDefault))
                {
                    WriteStartAttribute(reader.Prefix, reader.LocalName,
                                        reader.NamespaceURI);
                    while (reader.ReadAttributeValue())
                    {
                        if (reader.NodeType == XmlNodeType.EntityReference)
                        {
                            WriteEntityRef(reader.Name);
                        }
                        else
                        {
                            WriteString(reader.Value);
                        }
                    }
                    WriteEndAttribute();
                }
            }while(reader.MoveToNextAttribute());

            // Move back to the element if we started on one.
            if (reset)
            {
                reader.MoveToElement();
            }
        }
All Usage Examples Of System.Xml.XmlReader::ReadAttributeValue