Skip to content

Commit 1f50b5a

Browse files
ChrisMaddockmairaw
authored andcommitted
Add lang identifiers (dotnet#168)
1 parent 91e1202 commit 1f50b5a

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

xml/System.Xml/XmlTextReader.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
> [!NOTE]
283283
> In version 1.1 of the [!INCLUDE[dnprdnshort](~/includes/dnprdnshort-md.md)], partially trusted code cannot set the `XmlResolver` property. The workaround is to create an <xref:System.Xml.XmlUrlResolver> with the necessary credentials, pass the URI to the <xref:System.Xml.XmlUrlResolver.GetEntity%2A?displayProperty=nameWithType> method, and then construct the `XmlTextReader` using the resulting <xref:System.IO.Stream> object. The workaround is described in the following C# code.
284284
285-
```
285+
```csharp
286286
// Create a resolver with the necessary credentials.
287287
XmlUrlResolver resolver = new XmlUrlResolver();
288288
NetworkCredential nc = new NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword, SecurelyStoredDomain);
@@ -1510,20 +1510,20 @@ XmlTextReader reader = new XmlTextReader(s);
15101510
15111511
The following XML contains an attribute in a specific namespace:
15121512
1513-
```
1513+
```xml
15141514
<test xmlns:dt="urn:datatypes" dt:type="int"/>
15151515
```
15161516
15171517
You can lookup the `dt:type` attribute using one argument (prefix and local name) or two arguments (local name and namespace URI):
15181518
1519-
```
1519+
```csharp
15201520
String dt = reader.GetAttribute("dt:type");
15211521
String dt2 = reader.GetAttribute("type","urn:datatypes");
15221522
```
15231523
15241524
To lookup the `xmlns:dt` attribute, use one of the following arguments:
15251525
1526-
```
1526+
```csharp
15271527
String dt3 = reader.GetAttribute("xmlns:dt");
15281528
String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/);
15291529
```
@@ -2090,7 +2090,7 @@ abc<tag/>
20902090
20912091
In the following XML, if the reader is positioned on the `href` attribute, the prefix `a` is resolved by calling `reader.LookupNamespace("a")`. The returned string is `urn:456`.
20922092
2093-
```
2093+
```xml
20942094
<root xmlns:a="urn:456">
20952095
<item>
20962096
<ref href="a:b"/>
@@ -3225,7 +3225,7 @@ abc<tag/>
32253225
32263226
In the following XML, if the reader is positioned on the start tag, `ReadChars` returns `test` and positions the reader after the end tag.
32273227
3228-
```
3228+
```xml
32293229
<Item>test</Item>
32303230
```
32313231
@@ -3245,7 +3245,7 @@ abc<tag/>
32453245
32463246
For example, using the following XML:
32473247
3248-
```
3248+
```xml
32493249
<thing>
32503250
some text
32513251
</thing>
@@ -3255,7 +3255,7 @@ abc<tag/>
32553255
32563256
The reader is positioned on the `<item>` element at the end of the while loop.
32573257
3258-
```
3258+
```csharp
32593259
if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name)
32603260
{
32613261
while(0 != reader.ReadChars(buffer, 0, 1)
@@ -3818,7 +3818,7 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name)
38183818
38193819
If the reader is positioned on a leaf node already (such as the `<x>` node or the text node `abc`), calling `Skip` is the same as calling <xref:System.Xml.XmlTextReader.Read%2A>.
38203820
3821-
```
3821+
```xml
38223822
<a name="bob" age="123">
38233823
<x/>abc<y/>
38243824
</a>

xml/System.Xml/XmlTextWriter.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
4343
`XmlTextWriter` maintains a namespace stack corresponding to all the namespaces defined in the current element stack. Using `XmlTextWriter` you can declare namespaces manually.
4444
45-
```
45+
```csharp
4646
w.WriteStartElement("root");
4747
w.WriteAttributeString("xmlns", "x", null, "urn:1");
4848
w.WriteStartElement("item","urn:1");
@@ -54,7 +54,7 @@ w.WriteEndElement();
5454
5555
The above C# code produces the following output. `XmlTextWriter` promotes the namespace declaration to the root element to avoid having it duplicated on the two child elements. The child elements pick up the prefix from the namespace declaration.
5656
57-
```
57+
```xml
5858
<root xmlns:x="urn:1">
5959
<x:item/>
6060
<x:item/>
@@ -63,14 +63,14 @@ w.WriteEndElement();
6363
6464
`XmlTextWriter` also allows you to override the current namespace declaration. In the following example, the namespace URI "123" is overridden by "abc" to produce the XML element `<x:node xmlns:x="abc"/>`.
6565
66-
```
66+
```csharp
6767
w.WriteStartElement("x","node","123");
6868
w.WriteAttributeString("xmlns","x",null,"abc");
6969
```
7070
7171
By using the write methods that take a prefix as an argument you can also specify which prefix to use. In the following example, two different prefixes are mapped to the same namespace URI to produce the XML text `<x:root xmlns:x="urn:1"><y:item xmlns:y="urn:1"/></x:root>`.
7272
73-
```
73+
```csharp
7474
XmlTextWriter w = new XmlTextWriter(Console.Out);
7575
w.WriteStartElement("x","root","urn:1");
7676
w.WriteStartElement("y","item","urn:1");
@@ -81,7 +81,7 @@ w.Close();
8181
8282
If there are multiple namespace declarations mapping different prefixes to the same namespace URI, `XmlTextWriter` walks the stack of namespace declarations backwards and picks the closest one.
8383
84-
```
84+
```csharp
8585
XmlTextWriter w = new XmlTextWriter(Console.Out);
8686
w.Formatting = Formatting.Indented;
8787
w.WriteStartElement("x","root","urn:1");
@@ -94,7 +94,7 @@ w.Close();
9494
9595
In the above C# example, because the `WriteAttributeString` call does not specify a prefix, the writer uses the last prefix pushed onto the namespace stack, and produces the following XML:
9696
97-
```
97+
```xml
9898
<x:root xmlns:x="urn:1">
9999
<y:item y:attr="123" xmlns:y="urn:1" />
100100
</x:root>
@@ -110,7 +110,7 @@ w.Close();
110110
111111
To write strongly typed data, use the <xref:System.Xml.XmlConvert> class to convert data types to string. For example, the following C# code converts the data from `Double` to `String` and writes the element `<price>19.95</price>`.
112112
113-
```
113+
```csharp
114114
Double price = 19.95;
115115
writer.WriteElementString("price", XmlConvert.ToString(price));
116116
```
@@ -470,7 +470,7 @@ writer.WriteElementString("price", XmlConvert.ToString(price));
470470
471471
If the `Indented` option is set, child elements are indented using the <xref:System.Xml.XmlTextWriter.Indentation%2A> and <xref:System.Xml.XmlTextWriter.IndentChar%2A> properties. Only element content is indented. The following C# code writes out HTML elements including mixed content:
472472
473-
```
473+
```csharp
474474
XmlTextWriter w = new XmlTextWriter(Console.Out);
475475
w.Formatting = Formatting.Indented;
476476
w.WriteStartElement("ol");
@@ -485,7 +485,7 @@ XmlTextWriter w = new XmlTextWriter(Console.Out);
485485
486486
The above code produces the following output:
487487
488-
```
488+
```xml
489489
<ol>
490490
<li>The big <b>E</b><i>lephant</i> walks slowly.</li>
491491
</ol>
@@ -547,7 +547,7 @@ XmlTextWriter w = new XmlTextWriter(Console.Out);
547547
548548
Indentation is performed on following node types: `DocumentType`, `Element`, `Comment`, `ProcessingInstruction`, and `CDATASection`. All other node types are not affected. The `XmlTextWriter` does not indent the internal DTD subset. However, you could do the following to apply formatting to the internal DTD subset.
549549
550-
```
550+
```csharp
551551
String name = "Employees";
552552
String pubid = null;
553553
String sysid = null;
@@ -1621,7 +1621,7 @@ tw.WriteDocType(name, pubid, sysid, subset);
16211621
16221622
For example, the following Microsoft Visual C# code:
16231623
1624-
```
1624+
```csharp
16251625
writer.Formatting = Formatting.Indented;
16261626
writer.WriteStartElement("root");
16271627
writer.WriteAttributeString("xmlns","x",null,"urn:abc");
@@ -1637,7 +1637,7 @@ writer.WriteStartElement("root");
16371637
16381638
Generates the following output:
16391639
1640-
```
1640+
```xml
16411641
<root xmlns:x="urn:abc">
16421642
<item href="#x:test"/>
16431643
</root>

xml/System.Xml/XmlUrlResolver.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
166166
The following C# code shows how to set the <xref:System.Xml.XmlUrlResolver.Credentials%2A> property to a credential cache.
167167
168-
```
168+
```csharp
169169
NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain);
170170
CredentialCache myCache = new CredentialCache();
171171
myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred);

xml/System.Xml/XmlValidatingReader.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@
649649
650650
To illustrate the difference between the entity handling modes consider the following XML:
651651
652-
```
652+
```xml
653653
<!DOCTYPE doc [<!ENTITY num "123">]>
654654
<doc> &#65; &num; </doc>
655655
```
@@ -888,20 +888,20 @@
888888
889889
The following XML contains an attribute in a specific namespace:
890890
891-
```
891+
```xml
892892
<test xmlns:dt="urn:datatypes" dt:type="int"/>
893893
```
894894
895895
You can look up the `dt:type` attribute by using one argument (prefix and local name) or two arguments (local name and namespace URI):
896896
897-
```
897+
```csharp
898898
String dt = reader.GetAttribute("dt:type");
899899
String dt2 = reader.GetAttribute("type","urn:datatypes");
900900
```
901901
902902
To look up the `xmlns:dt` attribute, use one of the following arguments:
903903
904-
```
904+
```csharp
905905
String dt3 = reader.GetAttribute("xmlns:dt");
906906
String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/);
907907
```
@@ -1234,7 +1234,7 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/);
12341234
12351235
The position indicated is the first character of text in the markup.
12361236
1237-
```
1237+
```xml
12381238
<root>
12391239
abc<tag/>
12401240
</root>
@@ -1343,7 +1343,7 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/);
13431343
13441344
In the following XML string, if the reader is positioned on the `href` attribute, the prefix `a` is resolved by calling `reader.LookupNamespace("a", true)`. The returned string is `urn:456`.
13451345
1346-
```
1346+
```xml
13471347
<root xmlns:a="urn:456">
13481348
<item>
13491349
<ref href="a:b"/>
@@ -2138,7 +2138,7 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/);
21382138
21392139
If <xref:System.Xml.XmlValidatingReader.EntityHandling%2A> is set to `ExpandCharEntities`, the following C# code returns the attribute value as two text nodes and one entity reference node:
21402140
2141-
```
2141+
```csharp
21422142
reader.MoveToAttribute("name");
21432143
while (reader.ReadAttributeValue())
21442144
{
@@ -2840,7 +2840,7 @@ reader.MoveToAttribute("name");
28402840
28412841
The user needs to test for the returned type. For example,
28422842
2843-
```
2843+
```csharp
28442844
object obj = vreader.SchemaType;
28452845
if (obj is XmlSchemaType)
28462846
{
@@ -3279,7 +3279,7 @@ object obj = vreader.SchemaType;
32793279
32803280
This property represents the xml:lang scope within which the current node resides. For example, here is an XML fragment with `xml:lang` set to U.S. English in the root element:
32813281
3282-
```
3282+
```xml
32833283
<root xml:lang="en-us">
32843284
<name>Fred</name>
32853285
</root>

xml/System.Xml/XmlWriter.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
142142
The code generates the following XML string:
143143
144-
```
144+
```xml
145145
<x:root xmlns:x="123">
146146
<item xmlns:x="abc" />
147147
</x:root>
@@ -182,7 +182,7 @@
182182
## Examples
183183
The following example code shows how to use the asynchronous API to generate XML.
184184
185-
```
185+
```csharp
186186
async Task TestWriter(Stream stream)
187187
{
188188
XmlWriterSettings settings = new XmlWriterSettings();
@@ -3352,15 +3352,15 @@ async Task TestWriter(Stream stream)
33523352
33533353
The following C# code copies an entire XML input document to the console:
33543354
3355-
```
3355+
```csharp
33563356
XmlReader reader = XmlReader.Create(myfile);
33573357
XmlWriter writer = XmlWriter.Create(Console.Out);
33583358
writer.WriteNode(reader, false);
33593359
```
33603360
33613361
If you have moved off the root node and are positioned elsewhere in the document the following C# example correctly writes out the nodes.
33623362
3363-
```
3363+
```csharp
33643364
XmlReader reader = XmlReader.Create(myfile);
33653365
reader.Read(); // Read PI
33663366
reader.Read(); // Read Comment
@@ -3631,7 +3631,7 @@ while (!reader.EOF){
36313631
## Remarks
36323632
This method can be used to write the XML declaration (rather than <xref:System.Xml.XmlWriter.WriteStartDocument%2A>). This could result in the encoding attribute being incorrectly written. For example, the following C# code would result in an invalid XML document because the default encoding is UTF-8.
36333633
3634-
```
3634+
```csharp
36353635
XmlWriter writer = XmlWriter.Create("output.xml");
36363636
writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-16'");
36373637
writer.WriteStartElement("root");
@@ -3762,7 +3762,7 @@ writer.Close();
37623762
## Examples
37633763
The example writes the following element:
37643764
3765-
```
3765+
```xml
37663766
<root xmlns:x="urn:abc">
37673767
<item href="#x:test"/>
37683768
</root>
@@ -4647,15 +4647,15 @@ writer.Close();
46474647
## Remarks
46484648
After calling this method you can either write attributes, or create content using <xref:System.Xml.XmlWriter.WriteComment%2A>, <xref:System.Xml.XmlWriter.WriteString%2A>, or `WriteStartElement` for child elements. You can close the element with either <xref:System.Xml.XmlWriter.WriteEndElement%2A> or <xref:System.Xml.XmlWriter.WriteFullEndElement%2A>. For example, the following C# code:
46494649
4650-
```
4650+
```csharp
46514651
writer.WriteStartElement("item",null);
46524652
writer.WriteString("some text");
46534653
writer.WriteEndElement();
46544654
```
46554655
46564656
Generates the following output:
46574657
4658-
```
4658+
```xml
46594659
<item>some text</item>
46604660
```
46614661

xml/System.Xml/XmlWriterSettings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
6969
The sample produces the following output:
7070
71-
```
71+
```xml
7272
<order
7373
orderID="367A54"
7474
date="2001-05-03">
@@ -813,7 +813,7 @@ using (StreamWriter output =
813813
814814
The sample produces the following output:
815815
816-
```
816+
```xml
817817
<order
818818
orderID="367A54"
819819
date="2001-05-03">

0 commit comments

Comments
 (0)