注释风格:
1
' Start(Mod) 2005/12/02 谷常生 [00000007]
2
nShishaMeisaiNgFlg = 1
3
' End (Mod) 2005/12/02 谷常生 [00000007]
2
3
生成的XML格式如下:
1
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2
<?xml-stylesheet type="text/xsl" href="gucs.xslt"?>
3
<CountInformation>
4
<Item>
5
<FileName>E:\project\PRユーザ管理変更\03 製造\01 ソース\In-Process\PR_PORTAL\PR_USER\SCRIPT\PRU_AdmRegQreLstFtr.asp</FileName>
6
<Total>51</Total>
7
<CodeOnly>31</CodeOnly>
8
<Comment>13</Comment>
9
<Blank>7</Blank>
10
<CommentCode>2</CommentCode>
11
</Item>
12
<Item>
13
<FileName>E:\project\PRユーザ管理変更\03 製造\01 ソース\In-Process\PR_PORTAL\PR_USER\SCRIPT\PRU_CommonFunction.inc</FileName>
14
<Total>1163</Total>
15
<CodeOnly>655</CodeOnly>
16
<Comment>330</Comment>
17
<Blank>178</Blank>
18
<CommentCode>390</CommentCode>
19
</Item>
20
<Item>
21
<FileName>Total</FileName>
22
<Total>1214</Total>
23
<CodeOnly>686</CodeOnly>
24
<Comment>343</Comment>
25
<Blank>185</Blank>
26
<CommentCode>392</CommentCode>
27
</Item>
28
</CountInformation>
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
由于使用XmlDocument生成XML,不可能手动写字符串,只能使用系统提供的对象,找了半天的资料,最后还是在MSDN中找到了,以下为实现代码:
1
XmlProcessingInstruction xsl = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"gucs.xslt\"");
2
doc.InsertBefore(xsl, doc.DocumentElement);
2
这两行代码,就生成了这条XML语句:
1
<?xml-stylesheet type="text/xsl" href="./gucs.xslt"?>
使用XmlProcessingInstruction就可以了,就是这么方便,呵呵。