I have been now searching for some time tutorials and posts how to deserialize a complex XML Document to objects and use it in an silverlight application. I have seen a lot of tutorials and posts from 2008, 2009 and many which clearly do not work.. It is kinda easy to work with Hello World or a class “Person” but i can not find any good stuff about some complex xml files and objectaction on the data. The 3 lines of parsingcode are not the problem, but what does the c # code look like? How do i create all those classes? How to work with those objects?
Lets imagine you get from a Web Service a stream or you have a string in your logic like this. You have namespaces, attributes and 6 childnodes.
<?xml version="1.0" encoding="UTF-8"?>
<om:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:om="http://www.opengis.net/om/1.0">
<a name="a1">
<b>
<c id="1" name="C1">
<d id="1" name="D1">My name is D1</d>
<d id="2" name ="D2">My name is D2</d>
<e>
<f>this is f1</f>
</e>
</c>
<c id="2" name="C2">
<d id="3" name="D3">My name is D3</d>
<e>
<f>this is f2</f>
</e>
</c>
</b>
<b>
<c id="3" name="C3">
<d id="4" name="D5">My name is D4</d>
<d id="5" name="D5">My name is D5</d>
<d id="6" name="D6">My name is D6</d>
<d id="7" name="D7">My name is D7</d>
<e>
<f>this is f3</f>
</e>
</c>
</b>
</a>
</om:root>
1) Is there any website, which can create the classes and c# code to be able to work/store the data within a xml? You post your xml file and u get the sourcecode for your c # classes. Something like http://www.json2csharp.com
2) How would my classes, properties, etc look like? I would like to see one standard modern state of the art way how to deal with Properties, Attributes, Lists, etc. The complete code with “using xxx”! Please lets use standard serializer class which will work with Silverlight!
3)Some object action. Like
- give me all nom:c in a list
- give me the value from f in nom:c id=”2″
- put all b into a list
- give me all atributevalues from name=”” FROM all test:d nodes
just some serius practical queries and not those easymode get.me.person.name or book.name
edit: Ok, maybe this is to difficult. Can anyone post some Links where there is at least a kind of tutorial or a blog with some examples?
For generating c# classes from xml you can use Microsoft tool xsd.exe.