I'm reading xml from SQL server with VB.net using an XSD schema file. I have the code working fine, but I'd now like to change the code from reading a file on disk to reading the schema from the file as an embedded resource. Here's my code, what do I need to change?? Dim conString As String = "MyConnectionString" Dim strm As Stream Dim strmReader As StreamReader Dim cmd As New SqlXmlCommand(conString) Dim xmlDoc As New XmlDocument Dim strXML As String With cmd .CommandText = "MyXPath" .CommandType = SqlXmlCommandType.XPath .SchemaPath = "C:\MySchemaFile.xsd" '**I want this to be embedded!!** strm = .ExecuteStream End With strmReader = New StreamReader(strm) strXML = strmReader.ReadToEnd xmlDoc.LoadXml(strXML)
Like I said, the above code works fine, but I don't want a physical file location. Thanks!!! -Michael
mpalmer78
Posts
-
Read XSD from embedded resource with VB.NET -
VB.NET read XSD from embedded resourceI'm reading xml from SQL server with VB.net using an XSD schema file. I have the code working fine, but I'd now like to change the code from reading a file on disk to reading the schema from the file as an embedded resource. Here's my code, what do I need to change??
Dim conString As String = "MyConnectionString" Dim strm As Stream Dim strmReader As StreamReader Dim cmd As New SqlXmlCommand(conString) Dim xmlDoc As New XmlDocument Dim strXML As String With cmd .CommandText = "MyXPath" .CommandType = SqlXmlCommandType.XPath .SchemaPath = "C:\MySchemaFile.xsd" '**I want this to be embedded!!** strm = .ExecuteStream End With strmReader = New StreamReader(strm) strXML = strmReader.ReadToEnd xmlDoc.LoadXml(strXML)
Like I said, the above code works fine, but I don't want a physical file location. Thanks!!! -Michael