private void FinishDocument() { if (_writeState == WriteState.Attribute) { WriteEndAttribute(); } while (_depth > 0) { WriteEndElement(); } }