×
Namespaces

Variants
Actions

Talk:How to create a Data class from an XML document

From Nokia Developer Wiki
Jump to: navigation, search

Hamishwillee - Where is the next article

Hi Kiran

You write " will explain in my next article about how to de-serialize the response in data class's object." When is this planned, and if you are going to write it, can you link it? If not, please tidy this to a good state?

For my interest, why might you do this? I think what you're saying is that this will create a class object that you can use to parse this sort of XML into your UI. Is there no way to do this directly in XML rather than via another class you have to write. Is this similar in some way to the fact that you can't use SQL direclty, but have to write classes to access tables in your database?

Could you please also add other good references in this topic on MSDN etc?

Regards

H

hamishwillee 10:41, 25 April 2012 (EEST)

Kavit Patel - Re: Hamishwillee - Where is the next article

Hi Hamishwillee,

I have created next article, please visit http://www.developer.nokia.com/Community/Wiki/Deserialize_the_XML_response_to_a_Data_class

Also, Yes. We can directly parse the XML without having class. But this is the simplest way to have your data parsed. You don't need to even care about parsing the responses. Another thing is that it is better to have a data (model) class for your responses (As part of MVC or MVVM architecture), you treat your XML data classes same like other classes in your application, thus easily get the values to show in UI.

This is useful mainly if you are requesting to PHP or other servers rather than .NET, if it is .NET server then it is better and easier to add the service reference rather than doing all these stuffs.

If you look at the wiki page there are Employees & Employee Classes, which are created manually to use with XmlSerializer. If we make use of "XSD" tool then we can have those two classes created automatically by the tool and we can use these classes in same manner like classes created manually, for parsing purpose.

I searched for some references for you and found below two some useful.

References: 1) http://msdn.microsoft.com/en-us/library/x6c1kb0s%28v=VS.71%29.aspx 2) http://www.codeproject.com/Articles/12886/Simplifying-Serialization-and-De-serialization-Pro

Regards,

Kavit.

Kavit Patel 15:41, 25 April 2012 (EEST)

Hamishwillee - Thanks for the explanation

Hi Kavit

Thanks for the explanation.

I believe I understand what is going on now. You're creating class deserialise specific XML - and what this article shows is a way of creating the class using a tool rather than having to manually create it. Coming from the Qt world this looks a bit clunky compared to being able to automatically parse arbitrary parameters into a model using xpath. I guess though it is more efficient than having to look at parser output directly.

From a documentation point of view, the problem is that this is not explained - you need to add the explanation up the top in the introduction. If it were me I would also combine the two documents under a single one with title "Deserialising an XML document using a data class". Do you want me to do this merge for you?

Regards

H

hamishwillee 05:17, 26 April 2012 (EEST)

 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×