|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||
|
|
|
|||
|
Quote:
------------------------------------------------------------------------- Imports System.Xml Imports System.Xml.Schema Public Class XMLValidator Public Sub New() End Sub Public Function Validate(ByVal fileName As String) As Boolean If SchemaCollection Is Nothing Then Throw New Exception("Property 'Schema' not set") End If Dim ValidatingReader As XmlValidatingReader Try ValidatingReader = New XmlValidatingReader(New XmlTextReader(fileName)) ValidatingReader.Schemas.Add(SchemaCollection) ValidatingReader.ValidationType = ValidationType.Schema ' Set the validation event handler Dim valdel As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEvent) AddHandler ValidatingReader.ValidationEventHandler, valdel ' Read XML data While ValidatingReader.Read() End While Finally If Not ValidatingReader Is Nothing Then ValidatingReader.Close() End If End Try Return Message Is Nothing End Function Public Sub ValidationEvent(ByVal errorid As Object, ByVal args As ValidationEventArgs) ' Missing schema If (args.Severity = XmlSeverityType.Warning) Then Message = Message + "No schema found to enforce validation." Message = Message + vbCrLf ' Not a well formed XML ElseIf (args.Severity = XmlSeverityType.Error) Then Message = Message + args.Message Message = Message + vbCrLf End If ' XSD schema validation error If Not (args.Exception Is Nothing) Then ' Message = Message + args.Exception.ToString() Message = Message + "My guess. Line#: " + CType(args.Exception.LineNumber - 2, String) Message = Message + vbCrLf End If MessageCount += 1 End Sub Public ReadOnly Property ErrorMessage() As String Get Return Message End Get End Property Public WriteOnly Property Schema() As String Set(ByVal Value As String) Try SchemaCollection = New XmlSchemaCollection Dim Reader As New XmlTextReader(Value) If SchemaCollection.Add(Nothing, Reader) Is Nothing Then Throw New Exception("Schema file not loaded") End If Reader.Close() Catch ex As Exception SchemaCollection = Nothing Throw ex End Try End Set End Property Public ReadOnly Property Errors() As Integer Get Return Me.MessageCount End Get End Property Private SchemaCollection As XmlSchemaCollection Private Message As String = Nothing Private MessageCount As Integer = 0 End Class --------------------------------------------------------------------------- If not, you can try messing with the IO streams to make them direct memory strings loaded into streams. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two ASP.NET application in one virtual folder | pepe123 | C# Programming | 0 | 07-12-2007 05:18 AM |
| Application Starts Minimized | Lop | C# Programming | 2 | 05-01-2007 11:55 PM |
| MS-SQL deadlock and hang the Java application | reachpradeep | Database & Database Programming | 1 | 03-11-2007 04:20 AM |
| capture screen shot from an application during run time | engr | Visual Basic Programming | 1 | 01-29-2007 03:38 PM |
| Make application skinnable | Frantic | C# Programming | 2 | 09-28-2006 07:27 AM |
| Xav | ........ | 1455.48 |
| MeTh0Dz|Reb0rn | ........ | 1089.45 |
| WingedPanther | ........ | 977.76 |
| marwex89 | ........ | 962.9 |
| morefood2001 | ........ | 911.18 |
| John | ........ | 910.37 |
| Brandon W | ........ | 822.79 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 276.28 |
| dcs | ........ | 253.49 |
Goal: 100,000 Posts
Complete: 84%