-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathXmlWriter.xml
More file actions
7460 lines (6775 loc) · 479 KB
/
XmlWriter.xml
File metadata and controls
7460 lines (6775 loc) · 479 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="XmlWriter" FullName="System.Xml.XmlWriter">
<TypeSignature Language="C#" Value="public abstract class XmlWriter : IAsyncDisposable, IDisposable" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit XmlWriter extends System.Object implements class System.IAsyncDisposable, class System.IDisposable" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<TypeSignature Language="DocId" Value="T:System.Xml.XmlWriter" />
<TypeSignature Language="VB.NET" Value="Public MustInherit Class XmlWriter
Implements IAsyncDisposable, IDisposable" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<TypeSignature Language="F#" Value="type XmlWriter = class
 interface IAsyncDisposable
 interface IDisposable" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<TypeSignature Language="C++ CLI" Value="public ref class XmlWriter abstract : IAsyncDisposable, IDisposable" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<TypeSignature Language="C#" Value="public abstract class XmlWriter : IDisposable" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit XmlWriter extends System.Object implements class System.IDisposable" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<TypeSignature Language="VB.NET" Value="Public MustInherit Class XmlWriter
Implements IDisposable" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<TypeSignature Language="F#" Value="type XmlWriter = class
 interface IDisposable" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<TypeSignature Language="C++ CLI" Value="public ref class XmlWriter abstract : IDisposable" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="10.0.0.0" FrameworkAlternate="net-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="11.0.0.0" FrameworkAlternate="net-11.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Xml.ReaderWriter" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0">
<InterfaceName>System.IAsyncDisposable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.IDisposable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files that contain XML data.</summary>
<remarks>
<format type="text/markdown">< and [Namespaces in XML 1.0 (third edition)](https://www.w3.org/TR/REC-xml-names/) recommendations.
The members of the <xref:System.Xml.XmlWriter> class enable you to:
- Verify that the characters are legal XML characters and that element and attribute names are valid XML names.
- Verify that the XML document is well-formed.
- Encode binary bytes as Base64 or BinHex, and write out the resulting text.
- Pass values by using common language runtime types instead of strings, to avoid having to manually perform value conversions.
- Write multiple documents to one output stream.
- Write valid names, qualified names, and name tokens.
## Create an XML writer
To create an <xref:System.Xml.XmlWriter> instance, use the <xref:System.Xml.XmlWriter.Create*?displayProperty=nameWithType> method. To specify the set of features you want to enable on the XML writer, pass an <xref:System.Xml.XmlWriterSettings> to the <xref:System.Xml.XmlWriter.Create*> method. Otherwise, default settings are used. See the <xref:System.Xml.XmlWriter.Create*> reference pages for details.
## Specify the output format
The <xref:System.Xml.XmlWriterSettings> class includes several properties that control how <xref:System.Xml.XmlWriter> output is formatted:
|Property|Description|
|--------------|-----------------|
|<xref:System.Xml.XmlWriterSettings.Encoding>|Specifies the text encoding to use. The default is `Encoding.UTF8`.|
|<xref:System.Xml.XmlWriterSettings.Indent>|Indicates whether to indent elements. The default is `false` (no indentation).|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Specifies the character string to use when indenting. The default is two spaces.|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|Specifies the character string to use for line breaks. The default is `\r\n` (carriage return, line feed) for non-Unix platforms, and `\n` (line feed) for Unix platforms.|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|Specifies how to handle newline characters.|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|Indicates whether to write attributes on a new line. <xref:System.Xml.XmlWriterSettings.Indent> should be set to `true` when using this property. The default is `false`.|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|Indicates whether to write an XML declaration. The default is `false`.|
The <xref:System.Xml.XmlWriterSettings.Indent> and <xref:System.Xml.XmlWriterSettings.IndentChars> properties control how insignificant white space is formatted. For example, to indent element nodes:
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Xml/XmlWriter/Overview/writer_v2.vb" id="Snippet8":::
Use the <xref:System.Xml.XmlWriterSettings.NewLineOnAttributes> to write each attribute on a new line with one extra level of indentation:
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/System.Xml/XmlWriter/Overview/writer_v2.vb" id="Snippet9":::
## Data conformance
An XML writer uses two properties from the <xref:System.Xml.XmlWriterSettings> class to check for data conformance:
- The <xref:System.Xml.XmlWriterSettings.CheckCharacters> property instructs the XML writer to check characters and throw an <xref:System.Xml.XmlException> exception if any characters are outside the legal range, as defined by the W3C.
- The <xref:System.Xml.XmlWriterSettings.ConformanceLevel> property configures the XML writer to check that the stream being written complies with the rules for a well-formed XML 1.0 document or document fragment, as defined by the W3C. The three conformance levels are described in the following table. The default is <xref:System.Xml.ConformanceLevel.Document>. For details, see the <xref:System.Xml.XmlWriterSettings.ConformanceLevel?displayProperty=nameWithType> property and the <xref:System.Xml.ConformanceLevel?displayProperty=nameWithType> enumeration.
|Level|Description|
|-----------|-----------------|
|<xref:System.Xml.ConformanceLevel.Document>|The XML output conforms to the rules for a well-formed XML 1.0 document and can be processed by any conforming processor.|
|<xref:System.Xml.ConformanceLevel.Fragment>|The XML output conforms to the rules for a well-formed XML 1.0 document fragment.|
|<xref:System.Xml.ConformanceLevel.Auto>|The XML writer determines which level of conformation checking to apply (document or fragment) based on the incoming data.|
## Write elements
You can use the following <xref:System.Xml.XmlWriter> methods to write element nodes. For examples, see the methods listed.
|Use|To|
|---------|--------|
|<xref:System.Xml.XmlWriter.WriteElementString*>|Write an entire element node, including a string value.|
|<xref:System.Xml.XmlWriter.WriteStartElement*>|To write an element value by using multiple method calls. For example, you can call <xref:System.Xml.XmlWriter.WriteValue*> to write a typed value, <xref:System.Xml.XmlWriter.WriteCharEntity*> to write a character entity, <xref:System.Xml.XmlWriter.WriteAttributeString*> to write an attribute, or you can write a child element. This is a more sophisticated version of the <xref:System.Xml.XmlWriter.WriteElementString*> method.<br /><br />To close the element, you call the <xref:System.Xml.XmlWriter.WriteEndElement*> or <xref:System.Xml.XmlWriter.WriteFullEndElement*> method.|
|<xref:System.Xml.XmlWriter.WriteNode*>|To copy an element node found at the current position of an <xref:System.Xml.XmlReader> or <xref:System.Xml.XPath.XPathNavigator> object. When called, it copies everything from the source object to the <xref:System.Xml.XmlWriter> instance.|
## Write attributes
You can use the following <xref:System.Xml.XmlWriter> methods to write attributes on element nodes. These methods can also be used to create namespace declarations on an element, as discussed in the next section.
|Use|To|
|---------|--------|
|<xref:System.Xml.XmlWriter.WriteAttributeString*>|To write an entire attribute node, including a string value.|
|<xref:System.Xml.XmlWriter.WriteStartAttribute*>|To write the attribute value using multiple method calls. For example, you can call <xref:System.Xml.XmlWriter.WriteValue*> to write a typed value. This is a more sophisticated version of the <xref:System.Xml.XmlWriter.WriteElementString*> method.<br /><br />To close the element, you call the <xref:System.Xml.XmlWriter.WriteEndAttribute*> method.|
|<xref:System.Xml.XmlWriter.WriteAttributes*>|To copy all the attributes found at the current position of an <xref:System.Xml.XmlReader> object. The attributes that are written depend on the type of node the reader is currently positioned on:<br /><br />- For an attribute node, it writes the current attribute, and then the rest of the attributes until the element closing tag.<br />- For an element node, it writes all attributes contained by the element.<br />- For an XML declaration node, it writes all the attributes in the declaration.<br />- For all other node types, the method throws an exception.|
## Handle namespaces
Namespaces are used to qualify element and attribute names in an XML document. Namespace prefixes associate elements and attributes with namespaces, which are in turn associated with URI references. Namespaces create element and attribute name uniqueness in an XML document.
The <xref:System.Xml.XmlWriter> maintains a namespace stack that corresponds to all the namespaces defined in the current namespace scope. When writing elements and attributes you can utilize namespaces in the following ways:
- Declare namespaces manually by using the <xref:System.Xml.XmlWriter.WriteAttributeString*> method. This can be useful when you know how to best optimize the number of namespace declarations. For an example, see the <xref:System.Xml.XmlWriter.WriteAttributeString(System.String,System.String%2CSystem.String,System.String)> method.
- Override the current namespace declaration with a new namespace. In the following code, the <xref:System.Xml.XmlWriter.WriteAttributeString*> method changes the namespace URI for the `"x"` prefix from `"123"` to `"abc"`.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet18":::
:::code language="vb" source="~/snippets/visualbasic/System.Xml/XmlWriter/Overview/writer_v2.vb" id="Snippet18":::
The code generates the following XML string:
```xml
<x:root xmlns:x="123">
<item xmlns:x="abc" />
</x:root>
```
- Specify a namespace prefix when writing attributes or elements. Many of the methods used to write element and attributes enable you to do this. For example, the <xref:System.Xml.XmlWriter.WriteStartElement(System.String,System.String,System.String)> method writes a start tag and associates it with a specified namespace and prefix.
## Write typed data
The <xref:System.Xml.XmlWriter.WriteValue*> method accepts a common language runtime (CLR) object, converts the input value to its string representation according to XML schema definition language (XSD) data type conversion rules, and writes it out by using the <xref:System.Xml.XmlWriter.WriteString*> method. This is easier than using the methods in the <xref:System.Xml.XmlConvert> class to convert the typed data to a string value before writing it out.
When writing to text, the typed value is serialized to text by using the <xref:System.Xml.XmlConvert> rules for that schema type.
For default XSD data types that correspond to CLR types, see the <xref:System.Xml.XmlWriter.WriteValue*> method.
The <xref:System.Xml.XmlWriter> can also be used to write to an XML data store. For example, the <xref:System.Xml.XPath.XPathNavigator> class can create an <xref:System.Xml.XmlWriter> object to create nodes for an <xref:System.Xml.XmlDocument> object. If the data store has schema information available to it, the <xref:System.Xml.XmlWriter.WriteValue*> method throws an exception if you try to convert to a type that is not allowed. If the data store does not have schema information available to it, the <xref:System.Xml.XmlWriter.WriteValue*> method treats all values as an `xsd:anySimpleType` type.
## Close the XML writer
When you use <xref:System.Xml.XmlWriter> methods to output XML, the elements and attributes are not written until you call the <xref:System.Xml.XmlWriter.Close*> method. For example, if you are using <xref:System.Xml.XmlWriter> to populate an <xref:System.Xml.XmlDocument> object, you won't be able to see the written elements and attributes in the target document until you close the <xref:System.Xml.XmlWriter> instance.
## Asynchronous programming
Most of the <xref:System.Xml.XmlWriter> methods have asynchronous counterparts that have "Async" at the end of their method names. For example, the asynchronous equivalent of <xref:System.Xml.XmlWriter.WriteAttributeString*> is <xref:System.Xml.XmlWriter.WriteAttributeStringAsync*>.
For the <xref:System.Xml.XmlWriter.WriteValue*> method, which doesn't have an asynchronous counterpart, convert the return value to a string and use the <xref:System.Xml.XmlWriter.WriteStringAsync*> method instead.
## Security considerations
Consider the following when working with the <xref:System.Xml.XmlWriter> class:
- Exceptions thrown by the <xref:System.Xml.XmlWriter> can disclose path information that you do not want bubbled up to the app. Your app must catch exceptions and process them appropriately.
- <xref:System.Xml.XmlWriter> does not validate any data that is passed to the <xref:System.Xml.XmlWriter.WriteDocType*> or <xref:System.Xml.XmlWriter.WriteRaw*> method. You should not pass arbitrary data to these methods.
]]></format>
</remarks>
<example>
The following example code shows how to use the asynchronous API to generate XML.
<code language="csharp">
async Task TestWriter(Stream stream)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Async = true;
using (XmlWriter writer = XmlWriter.Create(stream, settings)) {
await writer.WriteStartElementAsync("pf", "root", "http://ns");
await writer.WriteStartElementAsync(null, "sub", null);
await writer.WriteAttributeStringAsync(null, "att", null, "val");
await writer.WriteStringAsync("text");
await writer.WriteEndElementAsync();
await writer.WriteProcessingInstructionAsync("pName", "pValue");
await writer.WriteCommentAsync("cValue");
await writer.WriteCDataAsync("cdata value");
await writer.WriteEndElementAsync();
await writer.FlushAsync();
}
}
</code></example>
<related type="Article" href="/dotnet/standard/data/xml/">XML Documents and Data</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected XmlWriter ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.#ctor" />
<MemberSignature Language="VB.NET" Value="Protected Sub New ()" />
<MemberSignature Language="C++ CLI" Value="protected:
 XmlWriter();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Xml.XmlWriter" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Close">
<MemberSignature Language="C#" Value="public virtual void Close ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Close() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Close" />
<MemberSignature Language="VB.NET" Value="Public Overridable Sub Close ()" />
<MemberSignature Language="F#" Value="abstract member Close : unit -> unit
override this.Close : unit -> unit" Usage="xmlWriter.Close " />
<MemberSignature Language="C++ CLI" Value="public:
 virtual void Close();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>When overridden in a derived class, closes this stream and the underlying stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Any elements or attributes left open are automatically closed.
> [!NOTE]
> When you use the <xref:System.Xml.XmlWriter> methods to output XML, the elements and attributes will not be written until you call the <xref:System.Xml.XmlWriter.Close*> method. For example, if you are using the XmlWriter to populate an <xref:System.Xml.XmlDocument>, until you close the <xref:System.Xml.XmlWriter>, you will not be able to observe the written elements and attributes in the target document.
## Examples
The following example writes an XML node.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">A call is made to write more output after <see langword="Close" /> has been called or the result of this call is an invalid XML document.
-or-
An <see cref="T:System.Xml.XmlWriter" /> method was called before a previous asynchronous operation finished. In this case, <see cref="T:System.InvalidOperationException" /> is thrown with the message "An asynchronous operation is already in progress."</exception>
</Docs>
</Member>
<MemberGroup MemberName="Create">
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance.</summary>
<remarks>
<format type="text/markdown">< that are available only on <xref:System.Xml.XmlWriter> objects created by the static <xref:System.Xml.XmlWriter.Create*> method.
If you use a <xref:System.Xml.XmlWriter.Create*> overload that doesn't accept an <xref:System.Xml.XmlWriterSettings> object, the following default writer settings are used:
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
> [!NOTE]
> Although .NET provides the <xref:System.Xml.XmlTextWriter> class, which is a concrete implementation of the <xref:System.Xml.XmlWriter> class, we recommend that you create <xref:System.Xml.XmlWriter> instances by using the <xref:System.Xml.XmlWriter.Create*> method.
]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.Stream output);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.IO.Stream output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.IO.Stream)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As Stream) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.IO.Stream -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create output" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::IO::Stream ^ output);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.IO.Stream" />
</Parameters>
<Docs>
<param name="output">The stream to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> writes XML 1.0 text syntax and appends it to the specified stream.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the specified stream.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you use this overload, an <xref:System.Xml.XmlWriterSettings> object with the following default settings is used to create the XML writer:
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
If you want to specify the features to support on the created writer, use an overload that takes an <xref:System.Xml.XmlWriterSettings> object as one of its arguments, and pass in an <xref:System.Xml.XmlWriterSettings> object with your custom settings.
Also, XmlWriter always writes a Byte Order Mark (BOM) to the underlying data stream; however, some streams must not have a BOM. To omit the BOM, create a new <xref:System.Xml.XmlWriterSettings> object and set the Encoding property to be a new <xref:System.Text.UTF8Encoding> object with the Boolean value in the constructor set to false.
## Examples
The following example writes an XML fragment to a memory stream. (It uses the <xref:System.Xml.XmlWriter.Create(System.IO.Stream,System.Xml.XmlWriterSettings)> overload, which also configures the settings on the new XML writer instance.)
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Create/writestream2.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriterSettings.CloseOutput/VB/writestream2.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.TextWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.IO.TextWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.IO.TextWriter)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As TextWriter) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.IO.TextWriter -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create output" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::IO::TextWriter ^ output);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.IO.TextWriter" />
</Parameters>
<Docs>
<param name="output">The <see cref="T:System.IO.TextWriter" /> to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> writes XML 1.0 text syntax and appends it to the specified <see cref="T:System.IO.TextWriter" />.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the specified <see cref="T:System.IO.TextWriter" />.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you use this overload, an <xref:System.Xml.XmlWriterSettings> object with default settings is used to create the XML writer.
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
If you want to specify the features to support on the created writer, use an overload that takes an <xref:System.Xml.XmlWriterSettings> object as one of its arguments, and pass in an <xref:System.Xml.XmlWriterSettings> object with your custom settings.
## Examples
The following example creates a writer that outputs to the console.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter_v2/VB/writer_v2.vb" id="Snippet3":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (string outputFileName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(string outputFileName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (outputFileName As String) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : string -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create outputFileName" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::String ^ outputFileName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="outputFileName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
</Parameters>
<Docs>
<param name="outputFileName">The file to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> creates a file at the specified path and writes to it in XML 1.0 text syntax. The <paramref name="outputFileName" /> must be a file system path.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the specified filename.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you use this overload, an <xref:System.Xml.XmlWriterSettings> object with default settings is used to create the XML writer.
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
If you want to specify the features to support on the created XML writer, use an overload that takes an <xref:System.Xml.XmlWriterSettings> object as one of its arguments, and pass in a <xref:System.Xml.XmlWriterSettings> object with your custom settings.
## Examples
The following example creates an <xref:System.Xml.XmlWriter> object and writes a book node.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter_v2/VB/writer_v2.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="outputFileName" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.Text.StringBuilder output);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.Text.StringBuilder output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.Text.StringBuilder)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As StringBuilder) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.Text.StringBuilder -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create output" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::Text::StringBuilder ^ output);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.Text.StringBuilder" />
</Parameters>
<Docs>
<param name="output">The <see cref="T:System.Text.StringBuilder" /> to which to write to. Content written by the <see cref="T:System.Xml.XmlWriter" /> is appended to the <see cref="T:System.Text.StringBuilder" />.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the specified <see cref="T:System.Text.StringBuilder" />.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you use this overload, an <xref:System.Xml.XmlWriterSettings> object with default settings is used to create the XML writer.
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
If you want to specify the features to support on the created XML writer, use an overload that takes an <xref:System.Xml.XmlWriterSettings> object as one of its arguments, and pass in a <xref:System.Xml.XmlWriterSettings> object with your custom settings.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.Xml.XmlWriter output);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.Xml.XmlWriter output) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.Xml.XmlWriter)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As XmlWriter) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.Xml.XmlWriter -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create output" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::Xml::XmlWriter ^ output);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.Xml.XmlWriter" />
</Parameters>
<Docs>
<param name="output">The <see cref="T:System.Xml.XmlWriter" /> object that you want to use as the underlying writer.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the specified <see cref="T:System.Xml.XmlWriter" /> object.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object that is wrapped around the specified <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method allows you add features to an underlying <xref:System.Xml.XmlWriter> object. The underlying <xref:System.Xml.XmlWriter> object can be an object created by the <xref:System.Xml.XmlWriter.Create*?displayProperty=nameWithType> method, or an object created using the <xref:System.Xml.XmlTextWriter> implementation.
When you use this overload, an <xref:System.Xml.XmlWriterSettings> object with default settings is used to create the XML writer.
|Setting|Default|
|-------------|-------------|
|<xref:System.Xml.XmlWriterSettings.CheckCharacters>|`true`|
|<xref:System.Xml.XmlWriterSettings.CloseOutput>|`false`|
|<xref:System.Xml.XmlWriterSettings.ConformanceLevel>|<xref:System.Xml.ConformanceLevel.Document?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Encoding>|<xref:System.Text.Encoding.UTF8?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.Indent>|`false`|
|<xref:System.Xml.XmlWriterSettings.IndentChars>|Two spaces|
|<xref:System.Xml.XmlWriterSettings.NamespaceHandling>|<xref:System.Xml.NamespaceHandling.Default> (no removal)|
|<xref:System.Xml.XmlWriterSettings.NewLineChars>|`\r\n` (carriage return, line feed) for non-Unix platforms, or `\n` (line feed) for Unix platforms|
|<xref:System.Xml.XmlWriterSettings.NewLineHandling>|<xref:System.Xml.NewLineHandling.Replace?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.NewLineOnAttributes>|`false`|
|<xref:System.Xml.XmlWriterSettings.OmitXmlDeclaration>|`false`|
|<xref:System.Xml.XmlWriterSettings.OutputMethod>|<xref:System.Xml.XmlOutputMethod.Xml?displayProperty=nameWithType>|
|<xref:System.Xml.XmlWriterSettings.WriteEndDocumentOnClose>|`true`|
If you want to specify the features to support on the created XML writer, use an overload that takes an <xref:System.Xml.XmlWriterSettings> object as one of its arguments, and pass in a <xref:System.Xml.XmlWriterSettings> object with your custom settings.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.Stream output, System.Xml.XmlWriterSettings? settings);" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.IO.Stream output, class System.Xml.XmlWriterSettings settings) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.IO.Stream,System.Xml.XmlWriterSettings)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As Stream, settings As XmlWriterSettings) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.IO.Stream * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create (output, settings)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::IO::Stream ^ output, System::Xml::XmlWriterSettings ^ settings);" />
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.Stream output, System.Xml.XmlWriterSettings settings);" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.IO.Stream" />
<Parameter Name="settings" Type="System.Xml.XmlWriterSettings">
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="output">The stream to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> writes XML 1.0 text syntax and appends it to the specified stream.</param>
<param name="settings">The <see cref="T:System.Xml.XmlWriterSettings" /> object used to configure the new <see cref="T:System.Xml.XmlWriter" /> instance. If this is <see langword="null" />, a <see cref="T:System.Xml.XmlWriterSettings" /> with default settings is used.
If the <see cref="T:System.Xml.XmlWriter" /> is being used with the <see cref="M:System.Xml.Xsl.XslCompiledTransform.Transform(System.String,System.Xml.XmlWriter)" /> method, you should use the <see cref="P:System.Xml.Xsl.XslCompiledTransform.OutputSettings" /> property to obtain an <see cref="T:System.Xml.XmlWriterSettings" /> object with the correct settings. This ensures that the created <see cref="T:System.Xml.XmlWriter" /> object has the correct output settings.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the stream and <see cref="T:System.Xml.XmlWriterSettings" /> object.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
XmlWriter always writes a Byte Order Mark (BOM) to the underlying data stream; however, some streams must not have a BOM. To omit the BOM, create a new <xref:System.Xml.XmlWriterSettings> object and set the Encoding property to be a new <xref:System.Text.UTF8Encoding> object with the Boolean value in the constructor set to false.
## Examples
The following example writes an XML fragment to a memory stream.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Create/writestream2.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriterSettings.CloseOutput/VB/writestream2.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.TextWriter output, System.Xml.XmlWriterSettings? settings);" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.IO.TextWriter output, class System.Xml.XmlWriterSettings settings) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.IO.TextWriter,System.Xml.XmlWriterSettings)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As TextWriter, settings As XmlWriterSettings) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.IO.TextWriter * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create (output, settings)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::IO::TextWriter ^ output, System::Xml::XmlWriterSettings ^ settings);" />
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.IO.TextWriter output, System.Xml.XmlWriterSettings settings);" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="output" Type="System.IO.TextWriter" />
<Parameter Name="settings" Type="System.Xml.XmlWriterSettings">
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="output">The <see cref="T:System.IO.TextWriter" /> to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> writes XML 1.0 text syntax and appends it to the specified <see cref="T:System.IO.TextWriter" />.</param>
<param name="settings">The <see cref="T:System.Xml.XmlWriterSettings" /> object used to configure the new <see cref="T:System.Xml.XmlWriter" /> instance. If this is <see langword="null" />, a <see cref="T:System.Xml.XmlWriterSettings" /> with default settings is used.
If the <see cref="T:System.Xml.XmlWriter" /> is being used with the <see cref="M:System.Xml.Xsl.XslCompiledTransform.Transform(System.String,System.Xml.XmlWriter)" /> method, you should use the <see cref="P:System.Xml.Xsl.XslCompiledTransform.OutputSettings" /> property to obtain an <see cref="T:System.Xml.XmlWriterSettings" /> object with the correct settings. This ensures that the created <see cref="T:System.Xml.XmlWriter" /> object has the correct output settings.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the <see cref="T:System.IO.TextWriter" /> and <see cref="T:System.Xml.XmlWriterSettings" /> objects.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example writes out an XML string.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Overview/writer_v2.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter_v2/VB/writer_v2.vb" id="Snippet4":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="output" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (string outputFileName, System.Xml.XmlWriterSettings? settings);" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(string outputFileName, class System.Xml.XmlWriterSettings settings) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.String,System.Xml.XmlWriterSettings)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (outputFileName As String, settings As XmlWriterSettings) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : string * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create (outputFileName, settings)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::String ^ outputFileName, System::Xml::XmlWriterSettings ^ settings);" />
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (string outputFileName, System.Xml.XmlWriterSettings settings);" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Xml.XmlWriter</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="outputFileName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<Parameter Name="settings" Type="System.Xml.XmlWriterSettings" Index="1" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1">
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="outputFileName">The file to which you want to write. The <see cref="T:System.Xml.XmlWriter" /> creates a file at the specified path and writes to it in XML 1.0 text syntax. The <paramref name="outputFileName" /> must be a file system path.</param>
<param name="settings">The <see cref="T:System.Xml.XmlWriterSettings" /> object used to configure the new <see cref="T:System.Xml.XmlWriter" /> instance. If this is <see langword="null" />, a <see cref="T:System.Xml.XmlWriterSettings" /> with default settings is used.
If the <see cref="T:System.Xml.XmlWriter" /> is being used with the <see cref="M:System.Xml.Xsl.XslCompiledTransform.Transform(System.String,System.Xml.XmlWriter)" /> method, you should use the <see cref="P:System.Xml.Xsl.XslCompiledTransform.OutputSettings" /> property to obtain an <see cref="T:System.Xml.XmlWriterSettings" /> object with the correct settings. This ensures that the created <see cref="T:System.Xml.XmlWriter" /> object has the correct output settings.</param>
<summary>Creates a new <see cref="T:System.Xml.XmlWriter" /> instance using the filename and <see cref="T:System.Xml.XmlWriterSettings" /> object.</summary>
<returns>An <see cref="T:System.Xml.XmlWriter" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example creates an <xref:System.Xml.XmlWriter> object with the defined settings.
:::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Create/writeindent.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriterSettings.Indent/VB/writeindent.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="outputFileName" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.Text.StringBuilder output, System.Xml.XmlWriterSettings? settings);" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Xml.XmlWriter Create(class System.Text.StringBuilder output, class System.Xml.XmlWriterSettings settings) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Xml.XmlWriter.Create(System.Text.StringBuilder,System.Xml.XmlWriterSettings)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (output As StringBuilder, settings As XmlWriterSettings) As XmlWriter" />
<MemberSignature Language="F#" Value="static member Create : System.Text.StringBuilder * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter" Usage="System.Xml.XmlWriter.Create (output, settings)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Xml::XmlWriter ^ Create(System::Text::StringBuilder ^ output, System::Xml::XmlWriterSettings ^ settings);" />
<MemberSignature Language="C#" Value="public static System.Xml.XmlWriter Create (System.Text.StringBuilder output, System.Xml.XmlWriterSettings settings);" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xml.ReaderWriter</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>