本文整理汇总了VB.NET中System.Xml.XmlWriter.WriteComment方法的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlWriter.WriteComment方法的具体用法?VB.NET XmlWriter.WriteComment怎么用?VB.NET XmlWriter.WriteComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteComment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Sample
Option Strict
Option Explicit
Imports System.IO
Imports System.Xml
Public Class Sample
Private Const filename As String = "sampledata.xml"
Public Shared Sub Main()
Dim settings As XmlWriterSettings = new XmlWriterSettings()
settings.Indent = true
Dim writer As XmlWriter = XmlWriter.Create(filename, settings)
' Write the Processing Instruction node.
Dim PItext As String = "type=""text/xsl"" href=""book.xsl"""
writer.WriteProcessingInstruction("xml-stylesheet", PItext)
'Write the DocumentType node.
writer.WriteDocType("book", Nothing, Nothing, "<!ENTITY h ""hardcover"">")
' Write a Comment node.
writer.WriteComment("sample XML")
' Write the root element.
writer.WriteStartElement("book")
' Write the genre attribute
writer.WriteAttributeString("genre", "novel")
' Write the ISBN attribute.
writer.WriteAttributeString("ISBN", "1-8630-014")
' Write the title.
writer.WriteElementString("title", "The Handmaid's Tale")
' Write the style element.
writer.WriteStartElement("style")
writer.WriteEntityRef("h")
writer.WriteEndElement()
' Write the price.
writer.WriteElementString("price", "19.95")
' Write CDATA.
writer.WriteCData("Prices 15% off!!")
' Write the close tag for the root element.
writer.WriteEndElement()
writer.WriteEndDocument()
' Write the XML to file and close the writer
writer.Flush()
writer.Close()
End Sub
End Class
示例2: MainClass
' 导入命名空间
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Public Class MainClass
Public Shared Sub Main()
Dim myXmlSettings As New XmlWriterSettings
myXmlSettings.Indent = True
myXmlSettings.NewLineOnAttributes = True
Using ProductWriter As XmlWriter = XmlWriter.Create("test.xml", myXmlSettings)
ProductWriter.WriteComment("www.java2s.com ")
ProductWriter.WriteStartElement("Product")
ProductWriter.WriteAttributeString("Id", "101")
ProductWriter.WriteAttributeString("COunt", "10")
ProductWriter.WriteElementString("P1", "P2")
ProductWriter.WriteEndElement()
End Using
End Sub
End Class