Validate XML data before DataSet.Read - httpRequest

T

Thiago Macedo

Hi,

I posted an issue on the .vb group that is related to the .Net
Framework 2.0.
Posting here for a larger abrangence:

i'm developing a windows application that gets data from an Mysql
database through PHP server-side scripts. I'm not totally familiar
with Requests and XML on .Net 2.0.
I'll load these sort of data - simply generated by the phps - into a
dataset and i want to validate, before, if the response from server
isn't anything other than an valid XML structure, to be able to catch
eventual server-side errors.
How this could be done? Load the data into a xml object and catch
parse errors?

Thanks for any appointments

Thiago

ref: http://groups.google.com/group/micr...read/thread/2b757f9bbfaa8380/1588e315e1c86624
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi,

I posted an issue on the .vb group that is related to the .Net
Framework 2.0.
Posting here for a larger abrangence:

i'm developing a windows application that gets data from an Mysql
database through PHP server-side scripts. I'm not totally familiar
with Requests and XML on .Net 2.0.
I'll load these sort of data - simply generated by the phps - into a
dataset and i want to validate, before, if the response from server
isn't anything other than an valid XML structure, to be able to catch
eventual server-side errors.
How this could be done? Load the data into a xml object and catch
parse errors?

Thanks for any appointments

Thiago

ref:http://groups.google.com/group/microsoft.public.dotnet.languages.vb/b....

Hi,

I think you can do it like that, simply try to load it in a XML and
catch any error
also you could start parsing it (in case you get no error) and catch
ahy possible error (like invalid data values) when you are creating
your dataset
 
P

Peter Bromberg [C# MVP]

If you use the DataSet's ReadXml method, you will either get a DataSet
because the XML is valid, or an exception. So all you need to do is code
defensively by catching the exception and showing an appropriate error
message to your user.
Peter
 
T

Thiago Macedo

If you use the DataSet's ReadXml method, you will either get a DataSet
because the XML is valid, or an exception. So all you need to do is code
defensively by catching the exception and showing an appropriate error
message to your user.

Right.
But while i'm developing in 2 ambients (server and windows client) i'm
trying to integrate the error handling. I'd like to show up, in
client, the PHP error message that would be generated by it, that in
case, would be the way to no valid XML return and ReadXML exception be
thrown.
But after ReadXml try to parse the XML Stream (and gets an exception)
i can't read its response anymore (forward-only), excepts if I run the
script again (till now is the unique way I see).

Thank you very much

Thiago
 
T

Thiago Macedo

Right.
But while i'm developing in 2 ambients (server and windows client) i'm
trying to integrate the error handling. I'd like to show up, in
client, the PHP error message that would be generated by it, that in
case, would be the way to no valid XML return and ReadXML exception be
thrown.
But after ReadXml try to parse the XML Stream (and gets an exception)
i can't read its response anymore (forward-only), excepts if I run the
script again (till now is the unique way I see).

Thank you very much

Thiago

Please, let me know if i'm completly wrong or don't make my self
clear.

Thiago
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top