When overridden in a derived class, writes out all the attributes found at the current position in the System.Xml.XmlReader.
Type Reason ArgumentNullException reader is null. InvalidOperationException The XmlWriter.WriteState is WriteState.Closed. System.Xml.XmlException reader is not positioned on a node of System.Xml.XmlNodeTypeAttribute, Element, or XmlDeclaration.
If the reader is positioned on an element node WriteAttributes copies all the contained attributes. If the reader is positioned on an attribute node, this method writes the current attribute, then the rest of the attributes until the element closing tag. If the reader is positioned on an XmlDeclaration node, this method writes all the attributes in the declaration. If the reader is positioned on any other node type this method throws an System.Xml.XmlException.
If this method is called using System.Xml.XmlValidatingReader, to ensure well-formed XML any content (which has been expanded from the entities) that could result in an invalid document is replaced when written. For example, if an attribute includes an > entity that has been expanded, to ensure a well-formed document the expanded > is replaced when written out with >.
For the asynchronous version of this method, see XmlWriter.WriteAttributesAsync(XmlReader, bool).