在緊挨著類(lèi)或成員的上一行打三個(gè)單引號(hào),自動(dòng)生成XML注釋。
創(chuàng)新互聯(lián)建站是專(zhuān)業(yè)的溫泉網(wǎng)站建設(shè)公司,溫泉接單;提供成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站,網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行溫泉網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
你可以使用para來(lái)?yè)Q行。
使用see cref來(lái)標(biāo)明參考項(xiàng)。
Dim s As String = "ipconfig" vbNewLine " address10.3.11.162/address" vbNewLine "/ipconfig"
System.IO.File.WriteAllText("C:\我的文件夾\我的文件.xml", s)
你也可以把內(nèi)容放進(jìn)textbox中,然后把textbox的內(nèi)容寫(xiě)進(jìn)去:
System.IO.File.WriteAllText("C:\我的文件夾\我的文件.xml", textbox1.text)
DataSet 和 DataTable都有現(xiàn)成的方法:WriteXml
DataTable tb = this.dataGridView1.DataSource as DataTable;
if(tb != null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView dv = this.dataGridView1.DataSource as DataView;
if(dv != null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList list = this.dataGridView1.DataSource as IList;
if(list != null)
{
//to do,如果是IList,就要你自己想辦法導(dǎo)出了
//XmlDocument or XmlWriter都可以考慮
}
DataSet
和
DataTable
都有現(xiàn)成的方法:WriteXml
DataTable
tb
=
this.
dataGridView
1.DataSource
as
DataTable;
if(tb
!=
null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView
dv
=
this.dataGridView1.DataSource
as
DataView;
if(dv
!=
null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList
list
=
this.dataGridView1.DataSource
as
IList;
if(list
!=
null)
{
//to
do,如果是IList,就要你自己想辦法導(dǎo)出了
//XmlDocument
or
XmlWriter
都可以考慮
}
使用System.XML
Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Xml
namespace HowTo.Samples.XML
public class WriteXmlFileSample
private const document as string = "newbooks.xml"
shared sub Main()
Dim myWriteXmlFileSample as WriteXmlFileSample
myWriteXmlFileSample = new WriteXmlFileSample()
myWriteXmlFileSample.Run(document)
end sub
public sub Run(args As String)
Dim myXmlTextReader as XmlTextReader = nothing
Dim myXmlTextWriter as XmlTextWriter = nothing
try
myXmlTextWriter = new XmlTextWriter (args, nothing)
myXmlTextWriter.Formatting = System.Xml.Formatting.Indented
myXmlTextWriter.WriteStartDocument(false)
myXmlTextWriter.WriteDocType("bookstore", nothing, "books.dtd", nothing)
myXmlTextWriter.WriteComment("此文件表示書(shū)店庫(kù)存數(shù)據(jù)庫(kù)的另一個(gè)片斷")
myXmlTextWriter.WriteStartElement("bookstore")
myXmlTextWriter.WriteStartElement("book", nothing)
myXmlTextWriter.WriteAttributeString("genre","autobiography")
myXmlTextWriter.WriteAttributeString("publicationdate","1979")
myXmlTextWriter.WriteAttributeString("ISBN","0-7356-0562-9")
myXmlTextWriter.WriteElementString("title", nothing, "The Autobiography of Mark Twain")
myXmlTextWriter.WriteStartElement("Author", nothing)
myXmlTextWriter.WriteElementString("first-name", "Mark")
myXmlTextWriter.WriteElementString("last-name", "Twain")
myXmlTextWriter.WriteEndElement()
myXmlTextWriter.WriteElementString("price", "7.99")
myXmlTextWriter.WriteEndElement()
myXmlTextWriter.WriteEndElement()
'向文件寫(xiě) XML 并關(guān)閉編寫(xiě)器
myXmlTextWriter.Flush()
myXmlTextWriter.Close()
' 讀取返回的文件并進(jìn)行分析以確保正確生成 XML
myXmlTextReader = new XmlTextReader (args)
FormatXml (myXmlTextReader, args)
catch e as Exception
Console.WriteLine ("異常:{0}", e.ToString())
finally
Console.WriteLine()
Console.WriteLine("對(duì)文件 {0} 的處理已完成。", args)
If Not myXmlTextReader Is Nothing
myXmlTextReader.Close()
end if
'關(guān)閉編寫(xiě)器
If Not myXmlTextWriter Is Nothing
myXmlTextWriter.Close()
end if
End try
End Sub
private shared Sub FormatXml (reader as XmlTextReader, filename as String)
Dim piCount, docCount, commentCount, elementCount as Integer
Dim attributeCount, textCount, whitespaceCount as Integer
While reader.Read()
Select (reader.NodeType)
case XmlNodeType.ProcessingInstruction:
Format (reader, "ProcessingInstruction")
piCount += 1
case XmlNodeType.DocumentType:
Format (reader, "DocumentType")
docCount += 1
case XmlNodeType.Comment:
Format (reader, "Comment")
commentCount += 1
case XmlNodeType.Element:
Format (reader, "Element")
elementCount += 1
While reader.MoveToNextAttribute()
Format (reader, "Attribute")
end While
if (reader.HasAttributes)
attributeCount += reader.AttributeCount
end if
case XmlNodeType.Text:
Format (reader, "Text")
textCount += 1
case XmlNodeType.Whitespace:
whitespaceCount += 1
End Select
End While
' 顯示該文件的統(tǒng)計(jì)信息
Console.WriteLine ()
Console.WriteLine("{0} 文件的統(tǒng)計(jì)信息", filename)
Console.WriteLine ()
Console.WriteLine("處理指令:" piCount)
Console.WriteLine("文檔類(lèi)型:" docCount)
Console.WriteLine("注釋?zhuān)? commentCount)
Console.WriteLine("元素:" elementCount)
Console.WriteLine("屬性:" attributeCount)
Console.WriteLine("文本:" textCount)
Console.WriteLine("空白:" whitespaceCount)
End Sub
private shared Sub Format(byref reader as XmlTextReader , NodeType as String)
' 格式化輸出
Console.Write(reader.Depth " ")
Console.Write(reader.AttributeCount " ")
Dim i as Integer
for i = 0 to reader.Depth - 1
Console.Write(Strings.chr(9))
Next
Console.Write(reader.Prefix NodeType "" reader.Name "" reader.Value)
Console.WriteLine()
End Sub
End Class
End Namespace
參考:
標(biāo)題名稱(chēng):vb.net生成xml的簡(jiǎn)單介紹
文章出自:http://www.chinadenli.net/article24/hpgpje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、建站公司、商城網(wǎng)站、面包屑導(dǎo)航、App設(shè)計(jì)、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)