13 private enum NamespaceState
16 NotDeclaredButInScope,
17 DeclaredButNotWrittenOut,
21 private struct TagInfo
25 internal string prefix;
27 internal string defaultNs;
29 internal NamespaceState defaultNsState;
33 internal string xmlLang;
35 internal int prevNsTop;
37 internal int prefixCount;
41 internal void Init(
int nsTop)
44 defaultNs =
string.Empty;
45 defaultNsState = NamespaceState.Uninitialized;
54 private struct Namespace
56 internal string prefix;
60 internal bool declared;
62 internal int prevNsIndex;
64 internal void Set(
string prefix,
string ns,
bool declared)
68 this.declared = declared;
73 private enum SpecialAttr
115 private XmlTextEncoder xmlEncoder;
121 private bool indented;
123 private int indentation;
125 private char indentChar;
127 private TagInfo[] stack;
131 private State[] stateTable;
133 private State currentState;
135 private Token lastToken;
137 private XmlTextWriterBase64Encoder base64Encoder;
139 private char quoteChar;
141 private char curQuoteChar;
143 private bool namespaces;
145 private SpecialAttr specialAttr;
147 private string prefixForXmlNs;
151 private Namespace[] nsStack;
157 private bool useNsHashtable;
159 private XmlCharType xmlCharType = XmlCharType.Instance;
161 private const int NamespaceStackInitialSize = 8;
163 private const int MaxNamespacesWalkCount = 16;
165 private static string[] stateName =
new string[10]
179 private static string[] tokenName =
new string[14]
197 private static readonly State[] stateTableDefault =
new State[104]
305 private static readonly State[] stateTableDocument =
new State[104]
429 if (currentState != 0)
488 public char QuoteChar
496 if (value !=
'"' && value !=
'\'')
501 xmlEncoder.QuoteChar = value;
511 switch (currentState)
520 case State.Attribute:
542 for (
int num = top; num > 0; num--)
544 XmlSpace xmlSpace = stack[num].xmlSpace;
560 for (
int num = top; num > 0; num--)
562 string xmlLang = stack[num].xmlLang;
572 internal XmlTextWriter()
580 stack =
new TagInfo[10];
584 stateTable = stateTableDefault;
585 currentState = State.Start;
586 lastToken = Token.Empty;
598 this.encoding = encoding;
599 if (encoding !=
null)
607 xmlEncoder =
new XmlTextEncoder(textWriter);
608 xmlEncoder.QuoteChar = quoteChar;
620 public XmlTextWriter(
string filename,
Encoding encoding)
632 xmlEncoder =
new XmlTextEncoder(w);
633 xmlEncoder.QuoteChar = quoteChar;
648 StartDocument(standalone ? 1 : 0);
658 if (currentState != State.Epilog)
660 if (currentState == State.Closed)
662 throw new ArgumentException(Res.GetString(
"Xml_ClosedOrError"));
664 throw new ArgumentException(Res.GetString(
"Xml_NoRoot"));
666 stateTable = stateTableDefault;
667 currentState = State.Start;
668 lastToken = Token.Empty;
672 currentState = State.Error;
685 public override void WriteDocType(
string name,
string pubid,
string sysid,
string subset)
689 ValidateName(name, isNCName:
false);
690 AutoComplete(Token.Doctype);
691 textWriter.
Write(
"<!DOCTYPE ");
692 textWriter.
Write(name);
695 textWriter.
Write(
" PUBLIC " + quoteChar.ToString());
696 textWriter.
Write(pubid);
697 textWriter.
Write(quoteChar.ToString() +
" " + quoteChar.ToString());
698 textWriter.
Write(sysid);
699 textWriter.
Write(quoteChar);
701 else if (sysid !=
null)
703 textWriter.
Write(
" SYSTEM " + quoteChar.ToString());
704 textWriter.
Write(sysid);
705 textWriter.
Write(quoteChar);
709 textWriter.
Write(
"[");
710 textWriter.
Write(subset);
711 textWriter.
Write(
"]");
713 textWriter.
Write(
'>');
717 currentState = State.Error;
727 public override void WriteStartElement(
string prefix,
string localName,
string ns)
731 AutoComplete(Token.StartElement);
733 textWriter.
Write(
'<');
736 stack[top].defaultNs = stack[top - 1].defaultNs;
737 if (stack[top - 1].defaultNsState != 0)
739 stack[top].defaultNsState = NamespaceState.NotDeclaredButInScope;
741 stack[top].mixed = stack[top - 1].mixed;
744 if (prefix !=
null && prefix.Length != 0 && LookupNamespace(prefix) == -1)
746 throw new ArgumentException(Res.GetString(
"Xml_UndefPrefix"));
749 else if (prefix ==
null)
751 string text = FindPrefix(ns);
758 PushNamespace(
null, ns, declared:
false);
761 else if (prefix.Length == 0)
763 PushNamespace(
null, ns, declared:
false);
771 VerifyPrefixXml(prefix, ns);
772 PushNamespace(prefix, ns, declared:
false);
774 stack[top].prefix =
null;
775 if (prefix !=
null && prefix.Length != 0)
777 stack[top].prefix = prefix;
778 textWriter.
Write(prefix);
779 textWriter.
Write(
':');
782 else if ((ns !=
null && ns.Length != 0) || (prefix !=
null && prefix.Length != 0))
784 throw new ArgumentException(Res.GetString(
"Xml_NoNamespaces"));
786 stack[top].name = localName;
787 textWriter.
Write(localName);
791 currentState = State.Error;
799 InternalWriteEndElement(longFormat:
false);
805 InternalWriteEndElement(longFormat:
true);
821 AutoComplete(Token.StartAttribute);
822 specialAttr = SpecialAttr.None;
825 if (prefix !=
null && prefix.Length == 0)
829 if (ns ==
"http://www.w3.org/2000/xmlns/" && prefix ==
null && localName !=
"xmlns")
835 if (localName ==
"lang")
837 specialAttr = SpecialAttr.XmlLang;
839 else if (localName ==
"space")
841 specialAttr = SpecialAttr.XmlSpace;
844 else if (prefix ==
"xmlns")
846 if (
"http://www.w3.org/2000/xmlns/" != ns && ns !=
null)
848 throw new ArgumentException(Res.GetString(
"Xml_XmlnsBelongsToReservedNs"));
850 if (localName ==
null || localName.Length == 0)
854 prefixForXmlNs =
null;
858 prefixForXmlNs = localName;
860 specialAttr = SpecialAttr.XmlNs;
862 else if (prefix ==
null && localName ==
"xmlns")
864 if (
"http://www.w3.org/2000/xmlns/" != ns && ns !=
null)
866 throw new ArgumentException(Res.GetString(
"Xml_XmlnsBelongsToReservedNs"));
868 specialAttr = SpecialAttr.XmlNs;
869 prefixForXmlNs =
null;
873 if (prefix !=
null && LookupNamespace(prefix) == -1)
875 throw new ArgumentException(Res.GetString(
"Xml_UndefPrefix"));
878 else if (ns.Length == 0)
880 prefix =
string.Empty;
884 VerifyPrefixXml(prefix, ns);
885 if (prefix !=
null && LookupNamespaceInCurrentScope(prefix) != -1)
889 string text = FindPrefix(ns);
890 if (text !=
null && (prefix ==
null || prefix == text))
898 prefix = GeneratePrefix();
900 PushNamespace(prefix, ns, declared:
false);
903 if (prefix !=
null && prefix.Length != 0)
905 textWriter.
Write(prefix);
906 textWriter.
Write(
':');
911 if ((ns !=
null && ns.Length != 0) || (prefix !=
null && prefix.Length != 0))
913 throw new ArgumentException(Res.GetString(
"Xml_NoNamespaces"));
915 if (localName ==
"xml:lang")
917 specialAttr = SpecialAttr.XmlLang;
919 else if (localName ==
"xml:space")
921 specialAttr = SpecialAttr.XmlSpace;
924 xmlEncoder.StartAttribute(specialAttr != SpecialAttr.None);
925 textWriter.
Write(localName);
926 textWriter.
Write(
'=');
927 if (curQuoteChar != quoteChar)
929 curQuoteChar = quoteChar;
930 xmlEncoder.QuoteChar = quoteChar;
932 textWriter.
Write(curQuoteChar);
936 currentState = State.Error;
946 AutoComplete(Token.EndAttribute);
950 currentState = State.Error;
963 AutoComplete(Token.CData);
966 throw new ArgumentException(Res.GetString(
"Xml_InvalidCDataChars"));
968 textWriter.
Write(
"<![CDATA[");
971 xmlEncoder.WriteRawWithSurrogateChecking(text);
973 textWriter.
Write(
"]]>");
977 currentState = State.Error;
990 if (text !=
null && (text.IndexOf(
"--",
StringComparison.Ordinal) >= 0 || (text.Length != 0 && text[text.Length - 1] ==
'-')))
992 throw new ArgumentException(Res.GetString(
"Xml_InvalidCommentChars"));
994 AutoComplete(Token.Comment);
995 textWriter.
Write(
"<!--");
998 xmlEncoder.WriteRawWithSurrogateChecking(text);
1000 textWriter.
Write(
"-->");
1004 currentState = State.Error;
1020 throw new ArgumentException(Res.GetString(
"Xml_InvalidPiChars"));
1022 if (
string.Compare(name,
"xml",
StringComparison.OrdinalIgnoreCase) == 0 && stateTable == stateTableDocument)
1024 throw new ArgumentException(Res.GetString(
"Xml_DupXmlDecl"));
1026 AutoComplete(Token.PI);
1027 InternalWriteProcessingInstruction(name, text);
1031 currentState = State.Error;
1043 ValidateName(name, isNCName:
false);
1044 AutoComplete(Token.Content);
1045 xmlEncoder.WriteEntityRef(name);
1049 currentState = State.Error;
1062 AutoComplete(Token.Content);
1063 xmlEncoder.WriteCharEntity(ch);
1067 currentState = State.Error;
1083 if (!xmlCharType.IsOnlyWhitespace(ws))
1085 throw new ArgumentException(Res.GetString(
"Xml_NonWhitespace"));
1087 AutoComplete(Token.Whitespace);
1088 xmlEncoder.Write(ws);
1092 currentState = State.Error;
1104 if (text !=
null && text.Length != 0)
1106 AutoComplete(Token.Content);
1107 xmlEncoder.Write(text);
1112 currentState = State.Error;
1125 AutoComplete(Token.Content);
1126 xmlEncoder.WriteSurrogateCharEntity(lowChar, highChar);
1130 currentState = State.Error;
1144 public override void WriteChars(
char[] buffer,
int index,
int count)
1148 AutoComplete(Token.Content);
1149 xmlEncoder.Write(buffer, index, count);
1153 currentState = State.Error;
1166 public override void WriteRaw(
char[] buffer,
int index,
int count)
1170 AutoComplete(Token.RawData);
1171 xmlEncoder.WriteRaw(buffer, index, count);
1175 currentState = State.Error;
1182 public override void WriteRaw(
string data)
1186 AutoComplete(Token.RawData);
1187 xmlEncoder.WriteRawWithSurrogateChecking(data);
1191 currentState = State.Error;
1206 public override void WriteBase64(
byte[] buffer,
int index,
int count)
1212 AutoComplete(Token.Base64);
1215 if (base64Encoder ==
null)
1217 base64Encoder =
new XmlTextWriterBase64Encoder(xmlEncoder);
1219 base64Encoder.Encode(buffer, index, count);
1223 currentState = State.Error;
1238 public override void WriteBinHex(
byte[] buffer,
int index,
int count)
1242 AutoComplete(Token.Content);
1243 BinHexEncoder.Encode(buffer, index, count,
this);
1247 currentState = State.Error;
1253 public override void Close()
1264 currentState = State.Closed;
1270 public override void Flush()
1279 public override void WriteName(
string name)
1283 AutoComplete(Token.Content);
1284 InternalWriteName(name, isNCName:
false);
1288 currentState = State.Error;
1303 AutoComplete(Token.Content);
1306 if (ns !=
null && ns.Length != 0 && ns != stack[top].defaultNs)
1308 string text = FindPrefix(ns);
1311 if (currentState != State.Attribute)
1313 throw new ArgumentException(Res.GetString(
"Xml_UndefNamespace", ns));
1315 text = GeneratePrefix();
1316 PushNamespace(text, ns, declared:
false);
1318 if (text.Length != 0)
1320 InternalWriteName(text, isNCName:
true);
1321 textWriter.
Write(
':');
1325 else if (ns !=
null && ns.Length != 0)
1327 throw new ArgumentException(Res.GetString(
"Xml_NoNamespaces"));
1329 InternalWriteName(localName, isNCName:
true);
1333 currentState = State.Error;
1345 if (ns ==
null || ns.Length == 0)
1347 throw new ArgumentException(Res.GetString(
"Xml_EmptyName"));
1349 string text = FindPrefix(ns);
1350 if (text ==
null && ns == stack[top].defaultNs)
1352 text =
string.Empty;
1365 AutoComplete(Token.Content);
1366 if (name ==
null || name.Length == 0)
1368 throw new ArgumentException(Res.GetString(
"Xml_EmptyName"));
1370 if (!ValidateNames.IsNmtokenNoNamespaces(name))
1372 throw new ArgumentException(Res.GetString(
"Xml_InvalidNameChars", name));
1374 textWriter.
Write(name);
1378 currentState = State.Error;
1383 private void StartDocument(
int standalone)
1387 if (currentState != 0)
1389 throw new InvalidOperationException(Res.GetString(
"Xml_NotTheFirst"));
1391 stateTable = stateTableDocument;
1392 currentState = State.Prolog;
1394 stringBuilder.
Append(
"version=" + quoteChar.ToString() +
"1.0" + quoteChar.ToString());
1395 if (encoding !=
null)
1397 stringBuilder.
Append(
" encoding=");
1398 stringBuilder.
Append(quoteChar);
1400 stringBuilder.
Append(quoteChar);
1402 if (standalone >= 0)
1404 stringBuilder.
Append(
" standalone=");
1405 stringBuilder.
Append(quoteChar);
1406 stringBuilder.
Append((standalone == 0) ?
"no" :
"yes");
1407 stringBuilder.
Append(quoteChar);
1409 InternalWriteProcessingInstruction(
"xml", stringBuilder.
ToString());
1413 currentState = State.Error;
1418 private void AutoComplete(Token token)
1420 if (currentState == State.Closed)
1422 throw new InvalidOperationException(Res.GetString(
"Xml_Closed"));
1424 if (currentState == State.Error)
1426 throw new InvalidOperationException(Res.GetString(
"Xml_WrongToken", tokenName[(
int)token], stateName[8]));
1428 State state = stateTable[(int)((
int)token * 8 + currentState)];
1429 if (state == State.Error)
1431 throw new InvalidOperationException(Res.GetString(
"Xml_WrongToken", tokenName[(
int)token], stateName[(
int)currentState]));
1436 if (indented && currentState != 0)
1438 Indent(beforeEndElement:
false);
1444 case Token.StartElement:
1445 if (currentState == State.Attribute)
1447 WriteEndAttributeQuote();
1448 WriteEndStartTag(empty:
false);
1450 else if (currentState == State.Element)
1452 WriteEndStartTag(empty:
false);
1454 if (token == Token.CData)
1456 stack[top].mixed =
true;
1458 else if (indented && currentState != 0)
1460 Indent(beforeEndElement:
false);
1463 case Token.EndElement:
1464 case Token.LongEndElement:
1469 if (currentState == State.Attribute)
1471 WriteEndAttributeQuote();
1473 if (currentState == State.Content)
1475 token = Token.LongEndElement;
1479 WriteEndStartTag(token == Token.EndElement);
1481 if (stateTableDocument == stateTable && top == 1)
1483 state = State.Epilog;
1486 case Token.StartAttribute:
1491 if (currentState == State.Attribute)
1493 WriteEndAttributeQuote();
1494 textWriter.
Write(
' ');
1496 else if (currentState == State.Element)
1498 textWriter.
Write(
' ');
1501 case Token.EndAttribute:
1506 WriteEndAttributeQuote();
1510 case Token.Whitespace:
1515 goto case Token.Base64;
1517 if (currentState == State.Element && lastToken != Token.Content)
1519 WriteEndStartTag(empty:
false);
1521 if (state == State.Content)
1523 stack[top].mixed =
true;
1527 throw new InvalidOperationException(Res.GetString(
"Xml_InvalidOperation"));
1529 currentState = state;
1533 private void AutoCompleteAll()
1545 private void InternalWriteEndElement(
bool longFormat)
1551 throw new InvalidOperationException(Res.GetString(
"Xml_NoStartTag"));
1553 AutoComplete(longFormat ? Token.LongEndElement : Token.EndElement);
1554 if (lastToken == Token.LongEndElement)
1558 Indent(beforeEndElement:
true);
1560 textWriter.
Write(
'<');
1561 textWriter.
Write(
'/');
1562 if (namespaces && stack[top].prefix !=
null)
1564 textWriter.
Write(stack[top].prefix);
1565 textWriter.
Write(
':');
1567 textWriter.
Write(stack[top].name);
1568 textWriter.
Write(
'>');
1570 int prevNsTop = stack[top].prevNsTop;
1571 if (useNsHashtable && prevNsTop < nsTop)
1573 PopNamespaces(prevNsTop + 1, nsTop);
1580 currentState = State.Error;
1585 private void WriteEndStartTag(
bool empty)
1587 xmlEncoder.StartAttribute(cacheAttrValue:
false);
1588 for (
int num = nsTop; num > stack[top].prevNsTop; num--)
1590 if (!nsStack[num].declared)
1592 textWriter.
Write(
" xmlns");
1593 textWriter.
Write(
':');
1594 textWriter.
Write(nsStack[num].prefix);
1595 textWriter.
Write(
'=');
1596 textWriter.
Write(quoteChar);
1597 xmlEncoder.Write(nsStack[num].ns);
1598 textWriter.
Write(quoteChar);
1601 if (stack[top].defaultNs != stack[top - 1].defaultNs && stack[top].defaultNsState == NamespaceState.DeclaredButNotWrittenOut)
1603 textWriter.
Write(
" xmlns");
1604 textWriter.
Write(
'=');
1605 textWriter.
Write(quoteChar);
1606 xmlEncoder.Write(stack[top].defaultNs);
1607 textWriter.
Write(quoteChar);
1608 stack[top].defaultNsState = NamespaceState.DeclaredAndWrittenOut;
1610 xmlEncoder.EndAttribute();
1613 textWriter.
Write(
" /");
1615 textWriter.
Write(
'>');
1618 private void WriteEndAttributeQuote()
1620 if (specialAttr != 0)
1622 HandleSpecialAttribute();
1624 xmlEncoder.EndAttribute();
1625 textWriter.
Write(curQuoteChar);
1628 private void Indent(
bool beforeEndElement)
1634 else if (!stack[top].mixed)
1637 int num = beforeEndElement ? (top - 1) : top;
1638 for (num *= indentation; num > 0; num--)
1640 textWriter.
Write(indentChar);
1645 private void PushNamespace(
string prefix,
string ns,
bool declared)
1647 if (
"http://www.w3.org/2000/xmlns/" == ns)
1649 throw new ArgumentException(Res.GetString(
"Xml_CanNotBindToReservedNamespace"));
1653 switch (stack[top].defaultNsState)
1657 case NamespaceState.Uninitialized:
1658 case NamespaceState.NotDeclaredButInScope:
1659 stack[top].defaultNs = ns;
1661 case NamespaceState.DeclaredButNotWrittenOut:
1664 stack[top].defaultNsState = (declared ? NamespaceState.DeclaredAndWrittenOut : NamespaceState.DeclaredButNotWrittenOut);
1667 if (prefix.Length != 0 && ns.Length == 0)
1669 throw new ArgumentException(Res.GetString(
"Xml_PrefixForEmptyNs"));
1671 int num = LookupNamespace(prefix);
1672 if (num != -1 && nsStack[num].ns == ns)
1676 nsStack[num].declared =
true;
1680 if (declared && num != -1 && num > stack[top].prevNsTop)
1682 nsStack[num].declared =
true;
1684 AddNamespace(prefix, ns, declared);
1687 private void AddNamespace(
string prefix,
string ns,
bool declared)
1690 if (num == nsStack.Length)
1693 Array.Copy(nsStack, destinationArray, num);
1694 nsStack = destinationArray;
1696 nsStack[num].Set(prefix, ns, declared);
1699 AddToNamespaceHashtable(num);
1704 for (
int i = 0; i <= num; i++)
1706 AddToNamespaceHashtable(i);
1708 useNsHashtable =
true;
1712 private void AddToNamespaceHashtable(
int namespaceIndex)
1714 string prefix = nsStack[namespaceIndex].prefix;
1715 if (nsHashtable.
TryGetValue(prefix, out
int value))
1717 nsStack[namespaceIndex].prevNsIndex = value;
1719 nsHashtable[prefix] = namespaceIndex;
1722 private void PopNamespaces(
int indexFrom,
int indexTo)
1724 for (
int num = indexTo; num >= indexFrom; num--)
1726 if (nsStack[num].prevNsIndex == -1)
1728 nsHashtable.Remove(nsStack[num].prefix);
1732 nsHashtable[nsStack[num].prefix] = nsStack[num].prevNsIndex;
1737 private string GeneratePrefix()
1739 int num = stack[top].prefixCount++;
1743 private void InternalWriteProcessingInstruction(
string name,
string text)
1745 textWriter.
Write(
"<?");
1746 ValidateName(name, isNCName:
false);
1747 textWriter.
Write(name);
1748 textWriter.
Write(
' ');
1751 xmlEncoder.WriteRawWithSurrogateChecking(text);
1753 textWriter.
Write(
"?>");
1756 private int LookupNamespace(
string prefix)
1760 if (nsHashtable.
TryGetValue(prefix, out
int value))
1767 for (
int num = nsTop; num >= 0; num--)
1769 if (nsStack[num].prefix == prefix)
1778 private int LookupNamespaceInCurrentScope(
string prefix)
1782 if (nsHashtable.
TryGetValue(prefix, out
int value) && value > stack[top].prevNsTop)
1789 for (
int num = nsTop; num > stack[top].prevNsTop; num--)
1791 if (nsStack[num].prefix == prefix)
1800 private string FindPrefix(
string ns)
1802 for (
int num = nsTop; num >= 0; num--)
1804 if (nsStack[num].ns == ns && LookupNamespace(nsStack[num].prefix) == num)
1806 return nsStack[num].prefix;
1812 private void InternalWriteName(
string name,
bool isNCName)
1814 ValidateName(name, isNCName);
1815 textWriter.
Write(name);
1818 private void ValidateName(
string name,
bool isNCName)
1820 if (name ==
null || name.Length == 0)
1822 throw new ArgumentException(Res.GetString(
"Xml_EmptyName"));
1824 int length = name.Length;
1828 int num2 = ValidateNames.ParseNCName(name);
1835 if (name[num2] !=
':' || isNCName || num != -1 || num2 <= 0 || num2 + 1 >= length)
1841 num2 += ValidateNames.ParseNmtoken(name, num2);
1844 else if (ValidateNames.IsNameNoNamespaces(name))
1848 throw new ArgumentException(Res.GetString(
"Xml_InvalidNameChars", name));
1851 private void HandleSpecialAttribute()
1853 string attributeValue = xmlEncoder.AttributeValue;
1854 switch (specialAttr)
1856 case SpecialAttr.XmlLang:
1857 stack[top].xmlLang = attributeValue;
1859 case SpecialAttr.XmlSpace:
1860 attributeValue = XmlConvert.TrimString(attributeValue);
1861 if (attributeValue ==
"default")
1863 stack[top].xmlSpace =
XmlSpace.Default;
1866 if (attributeValue ==
"preserve")
1868 stack[top].xmlSpace =
XmlSpace.Preserve;
1871 throw new ArgumentException(Res.GetString(
"Xml_InvalidXmlSpace", attributeValue));
1872 case SpecialAttr.XmlNs:
1873 VerifyPrefixXml(prefixForXmlNs, attributeValue);
1874 PushNamespace(prefixForXmlNs, attributeValue, declared:
true);
1879 private void VerifyPrefixXml(
string prefix,
string ns)
1881 if (prefix !=
null && prefix.Length == 3 && (prefix[0] ==
'x' || prefix[0] ==
'X') && (prefix[1] ==
'm' || prefix[1] ==
'M') && (prefix[2] ==
'l' || prefix[2] ==
'L') &&
"http://www.w3.org/XML/1998/namespace" != ns)
1883 throw new ArgumentException(Res.GetString(
"Xml_InvalidPrefix"));
1887 private void PushStack()
1889 if (top == stack.Length - 1)
1891 TagInfo[] destinationArray =
new TagInfo[stack.Length + 10];
1894 Array.Copy(stack, destinationArray, top + 1);
1896 stack = destinationArray;
1899 stack[top].Init(nsTop);
1902 private void FlushEncoders()
1904 if (base64Encoder !=
null)
1906 base64Encoder.Flush();
Represents a character encoding.To browse the .NET Framework source code for this type,...
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
abstract void WriteBase64(byte[] buffer, int index, int count)
When overridden in a derived class, encodes the specified binary bytes as Base64 and writes out the r...
Indicates that the prolog is being written.
abstract void WriteChars(char[] buffer, int index, int count)
When overridden in a derived class, writes text one buffer at a time.
int Indentation
Gets or sets how many IndentChars to write for each level in the hierarchy when P:System....
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
virtual void WriteBinHex(byte[] buffer, int index, int count)
When overridden in a derived class, encodes the specified binary bytes as BinHex and writes out the r...
static XmlWriter Create(string outputFileName)
Creates a new T:System.Xml.XmlWriter instance using the specified filename.
abstract void WriteStartDocument()
When overridden in a derived class, writes the XML declaration with the version "1....
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
The T:System.Diagnostics.EventLog can write to existing logs, and create event sources and logs.
FileMode
Specifies how the operating system should open a file.
No initialization action.
EditorBrowsableState
Specifies the browsable state of a property or method from within an editor.
Represents the base class for custom attributes.
The T:System.Diagnostics.PerformanceCounter can read categories.
abstract void WriteEndAttribute()
When overridden in a derived class, closes the previous M:System.Xml.XmlWriter.WriteStartAttribute(Sy...
void WriteStartAttribute(string localName, string ns)
Writes the start of an attribute with the specified local name and namespace URI.
abstract void WriteWhitespace(string ws)
When overridden in a derived class, writes out the given white space.
virtual void WriteQualifiedName(string localName, string ns)
When overridden in a derived class, writes out the namespace-qualified name. This method looks up the...
The code generator produces code for the contents of the object, rather than for the object itself.
abstract void WriteString(string text)
When overridden in a derived class, writes the given text content.
virtual string XmlLang
When overridden in a derived class, gets the current xml:lang scope.
abstract void WriteEndDocument()
When overridden in a derived class, closes any open elements or attributes and puts the writer back i...
abstract string LookupPrefix(string ns)
When overridden in a derived class, returns the closest prefix defined in the current namespace scope...
Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files t...
virtual void WriteNmToken(string name)
When overridden in a derived class, writes out the specified name, ensuring it is a valid NmToken acc...
abstract void Flush()
When overridden in a derived class, flushes whatever is in the buffer to the underlying streams and a...
Implements a T:System.IO.TextWriter for writing characters to a stream in a particular encoding....
abstract Encoding Encoding
When overridden in a derived class, returns the character encoding in which the output is written.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
virtual string WebName
When overridden in a derived class, gets the name registered with the Internet Assigned Numbers Autho...
abstract void WriteFullEndElement()
When overridden in a derived class, closes one element and pops the corresponding namespace scope.
virtual XmlSpace XmlSpace
When overridden in a derived class, gets an T:System.Xml.XmlSpace representing the current xml:space ...
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
Represents a writer that provides a fast, non-cached, forward-only way of generating streams or files...
abstract void WriteCharEntity(char ch)
When overridden in a derived class, forces the generation of a character entity for the specified Uni...
Represents a writer that can write a sequential series of characters. This class is abstract.
abstract void WriteCData(string text)
When overridden in a derived class, writes out a <![CDATA[...]]> block containing the specified text.
An end element tag (for example, </item> ).
abstract void WriteDocType(string name, string pubid, string sysid, string subset)
When overridden in a derived class, writes the DOCTYPE declaration with the specified name and option...
abstract void WriteEndElement()
When overridden in a derived class, closes one element and pops the corresponding namespace scope.
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
char IndentChar
Gets or sets which character to use for indenting when P:System.Xml.XmlTextWriter....
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
abstract void WriteSurrogateCharEntity(char lowChar, char highChar)
When overridden in a derived class, generates and writes the surrogate character entity for the surro...
Formatting Formatting
Indicates how the output is formatted.
abstract void WriteEntityRef(string name)
When overridden in a derived class, writes out an entity reference as &name;.
abstract void WriteRaw(char[] buffer, int index, int count)
When overridden in a derived class, writes raw markup manually from a character buffer.
The exception that is thrown when one of the arguments provided to a method is not valid.
virtual void Close()
When overridden in a derived class, closes this stream and the underlying stream.
This value supports the .NET Framework infrastructure and is not intended to be used directly from yo...
FileAccess
Defines constants for read, write, or read/write access to a file.
abstract void WriteComment(string text)
When overridden in a derived class, writes out a comment <!–...–> containing the specified text.
bool Namespaces
Gets or sets a value indicating whether to do namespace support.
virtual void WriteLine()
Writes a line terminator to the text string or stream.
virtual void Close()
Closes the current writer and releases any system resources associated with the writer.
Formatting
Specifies formatting options for the T:System.Xml.XmlTextWriter.
The exception that is thrown when a method call is invalid for the object's current state.
abstract void WriteProcessingInstruction(string name, string text)
When overridden in a derived class, writes out a processing instruction with a space between the name...
XmlSpace
Specifies the current xml:space scope.
Provides information about a specific culture (called a locale for unmanaged code development)....
virtual void Write(char value)
Writes a character to the text string or stream.
Stream BaseStream
Gets the underlying stream object.
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
abstract WriteState WriteState
When overridden in a derived class, gets the state of the writer.
virtual void WriteName(string name)
When overridden in a derived class, writes out the specified name, ensuring it is a valid name accord...
FileShare
Contains constants for controlling the kind of access other T:System.IO.FileStream objects can have t...
void WriteStartElement(string localName, string ns)
When overridden in a derived class, writes the specified start tag and associates it with the given n...
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....