本文整理匯總了VB.NET中System.Diagnostics.XmlWriterTraceListener類的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlWriterTraceListener類的具體用法?VB.NET XmlWriterTraceListener怎麽用?VB.NET XmlWriterTraceListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了XmlWriterTraceListener類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: testClass
' 導入命名空間
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Diagnostics
Class testClass
Shared Sub Main()
File.Delete("NotEscaped.xml")
Dim ts As New TraceSource("TestSource")
ts.Listeners.Add(New XmlWriterTraceListener("NotEscaped.xml"))
ts.Switch.Level = SourceLevels.All
Dim testString As String = "<Test><InnerElement Val=""1"" /><InnerElement Val=""Data""/><AnotherElement>11</AnotherElement></Test>"
Dim myXml As New XmlTextReader(New StringReader(testString))
Dim xDoc As New XPathDocument(myXml)
Dim myNav As XPathNavigator = xDoc.CreateNavigator()
ts.TraceData(TraceEventType.Error, 38, myNav)
ts.Flush()
ts.Close()
File.Delete("Escaped.xml")
Dim ts2 As New TraceSource("TestSource2")
ts2.Listeners.Add(New XmlWriterTraceListener("Escaped.xml"))
ts2.Switch.Level = SourceLevels.All
ts2.TraceData(TraceEventType.Error, 38, testString)
ts2.Flush()
ts2.Close()
End Sub
End Class