473,382 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Want to replace obsolete methods

I have been using the code below to validate an XML document with an XML
schema. If the XML is not valid, then the procedure throws an exception. I
have upgraded the application using this proc to DotNet 2 and Visual Studio
says that I'm using obsolete methods:

XmlValidatingReader : should be using XmlReader.Create
XmlSchemaCollection : should be using Xml.Schema.XmlSchemaSet

Any ideas how I can re-write this proc without using obsolete methods ?

- Craig
Public Shared Sub Validate(ByVal xmlPath As String, ByVal xsdPath As
String)

Dim reader As New XmlTextReader(xmlPath)
Dim validatingReader As New XmlValidatingReader(reader)
validatingReader.ValidationType = ValidationType.Schema

Dim schemaCollection As New XmlSchemaCollection
schemaCollection.Add(Nothing, xsdPath)
validatingReader.Schemas.Add(schemaCollection)

Do While validatingReader.Read
'validate xml
Loop

validatingReader.Close()

End Sub
Nov 8 '06 #1
2 4189
Just to add to my question...

If there is a better way to test whether some XML is valid, please let me know
Nov 8 '06 #2
Dim settings As New XmlReaderSettings()
settings.ValidationType = ValidationType.Schema
settings.Schemas.Add(Nothing, xsdPath)
XmlReader validatingReader = XmlReader.Create(xmlPath, settings);

Check out http://msdn2.microsoft.com/en-US/library/9khb6435.aspx for more
information.

Thank you,
-Helena Kotas


"Craig HB" wrote:
I have been using the code below to validate an XML document with an XML
schema. If the XML is not valid, then the procedure throws an exception. I
have upgraded the application using this proc to DotNet 2 and Visual Studio
says that I'm using obsolete methods:

XmlValidatingReader : should be using XmlReader.Create
XmlSchemaCollection : should be using Xml.Schema.XmlSchemaSet

Any ideas how I can re-write this proc without using obsolete methods ?

- Craig
Public Shared Sub Validate(ByVal xmlPath As String, ByVal xsdPath As
String)

Dim reader As New XmlTextReader(xmlPath)
Dim validatingReader As New XmlValidatingReader(reader)
validatingReader.ValidationType = ValidationType.Schema

Dim schemaCollection As New XmlSchemaCollection
schemaCollection.Add(Nothing, xsdPath)
validatingReader.Schemas.Add(schemaCollection)

Do While validatingReader.Read
'validate xml
Loop

validatingReader.Close()

End Sub
Nov 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TC | last post by:
I have a deployment project which is supposed to install an application to the Program Files folder. I have set RemovePreviousVersions = True. Nevertheless, I find that the obsolete version of one...
0
by: jbeerni | last post by:
In .NET, you can mark methods and accessors as obsolete by using the directive. I've found some interesting behavior with the directive when used in a class which is referenced as a return type...
4
by: BrianProgrammer | last post by:
I have this code below, that works like a champ, but two lines are continually marked as obsolete. See embeded notes. Private Shared Function TransformHTMLString(ByVal XSLT As String, _ ByVal...
16
by: BBM | last post by:
This is so bizarre I hesitate to post it, but I need to get this working. My code looks like this... Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _ " WHERE Scenario =...
0
by: SenthilVel | last post by:
Hi I am building my Dotnet Framework 1.1 C# code with VS2005 (Framework2.0) . For this process i use NAnt 0.85 RC4 Version. During the Build i get errors like : 1. "Method is Deprecated"...
16
by: cj | last post by:
I am under the impression they are obsolete methods included for backward compatibility. For instance is using filedatetime("c:\myfile.txt") still the accepted way of getting the date...
5
by: Andrus | last post by:
In code below line ICodeCompiler loCompiler = new CSharpCodeProvider().CreateCompiler(); in .net 2 causes warning 'System.CodeDom.Compiler.CodeDomProvider.CreateCompiler()' is obsolete:...
5
by: John | last post by:
Hi I am getting obsolete function warnings on these two liens but can't figure the correct syntax for the new equivalent functions; ConfigurationSettings.AppSettings.Get(key)...
2
by: John | last post by:
Hi I am getting a 'function is obsolete' warning on the following two statements; ConfigurationSettings.AppSettings.Get(Key) and Dns.GetHostByName(strServer)
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.