xml-deserialization

Deserialization XML to object with list in c#

三世轮回 提交于 2019-12-13 02:54:07
问题 I want to deserialize XML to object in C#, object has one string property and list of other objects. There are classes which describe XML object, my code doesn't work (it is below, XML is at end of my post). My Deserialize code doesn't return any object. I think I do something wrong with attributes, could you check it and give me some advice to fix it. Thanks for your help. [XmlRoot("shepherd")] public class Shepherd { [XmlElement("name")] public string Name { get; set; } [XmlArray

WCF deserializing - choosing type in depends on some field - once and for all deciding this issue

独自空忆成欢 提交于 2019-12-13 00:38:32
问题 Is it possible to help deserializer of WCF ? I mean that in my soap messages I send some special field like: <someField>someValue</someField> And based on this someField I give a hint to WCF deserializer what type it should deserialize ? 来源: https://stackoverflow.com/questions/43506726/wcf-deserializing-choosing-type-in-depends-on-some-field-once-and-for-all-de

deserialize existing xml into custom object

落爺英雄遲暮 提交于 2019-12-12 22:34:30
问题 I have the following xml: <state> <groups> <group id='1' name='Basic Search Options'> <control name='Building' label='In' display='true' configurable='false'/> <control name='SearchType' label='For' display='true' configurable='false'/> <control id='1' default='C' name='Search By' label='By'> <option searchtype='C' searchmode='Cnumber' value='CNumber' label='C Number' display='true'/> <option searchtype='C' searchmode='crossrefnumber' value='CNumber1' label='Cross Reference Number' display=

Hook in to OnDeserializing for XmlSerializer

柔情痞子 提交于 2019-12-12 20:40:18
问题 Otherwise than pointed out in this post I would like to act just before an XmlSerializer starts deserializing (not when finished deserializing) Background: I have a baseClass that implements INotifyPropertyChanged . This BaseClass is stored as xml in a database and when retrieved deserialized into an object instance. The deserialization executes the setters of this class where my ChangeNotification takes place. On a centralised handler for the changenotification I set the status of the object

Generic XML Deserialization into Undefined Objects

北城余情 提交于 2019-12-12 14:24:17
问题 I have a very long, very varied XML file that I am attempting to store portions of into a database. Now, I do not want to go through and hand-write 10,000 different objects to store the deserialized data into. Is there any way to define an Object based on what is found in the XML file? For instance, if I had: <objecttype1> <attr1>Some string of text</attr1> </objecttype1> <objecttype1> <attr2>123456789</attr2> </objecttype1> I would want an object similar to the following to be defined:

Deserialize a portion of xml into classes

时光毁灭记忆、已成空白 提交于 2019-12-12 12:26:27
问题 So if I have 3 different files that contain extremely long and complex xml (which i've abbreviated here) but just the root element name is different (not really random but I'd rather not duplicate classes for the same xml): File 1 <?xml version="1.0"?> <somerootname1> <car> <make>honda</make> <model>civic</model> </car> </somerootname1> File 2 <?xml version="1.0"?> <somerootname2> <car> <make>honda</make> <model>civic</model> </car> </somerootname2> File 3 <?xml version="1.0"?> <somerootname3

Unmarshalling SOAP Envelope from file in Java

不羁岁月 提交于 2019-12-12 12:13:08
问题 I want to unit-test the mapper objects that map/translate web service types generated by wsimport in to my own domain objects. I also want to test error-scenarios, such as SOAP faults and such, and I am thinking it would be best to test the mapper objects on authentic SOAP responses. I do not want to fire requests to the web service itself as this requires access to the web service, and poses round-trip time for each test. Given this scenario, I am seeking to unmarshal SOAP messages from a

Given System.Type T, Deserialize List<T>

倖福魔咒の 提交于 2019-12-12 05:48:42
问题 I have a number of classes that I want to serialize and de-serialize. I am trying to create a function that, given a type ("User", "Administrator", "Article", etc) will de-serialize the file with the list of those items. For example: /* I want to be able to do this */ List<Article> allArticles = GetAllItems(typeof(Article)); I cannot figure out how to achieve the above, but I managed to get this working: /* BAD: clumsy method - have to pass a (typeof(List<Article>)) instead of typeof(Article)

How to mark up your C# object to Deserialize this XML

可紊 提交于 2019-12-12 05:11:07
问题 I can't believe how unbelievably complicated this has been... I have the following XML... <Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://mynamespace.com/books"> <Rows> <Row> <Author><Name>Stephen King</Name></Author> </Row> </Rows> </Library> I would like the Deserialized C# object to read like... Library.Books[0].Author I have tried a million different combination of XML Attribute Markings to Deserialize, such as...

Deserializing XML in C# where a property could be either an attribute or an element

北城以北 提交于 2019-12-12 03:54:27
问题 I'm writing a C# library that, as one of its functions, needs to be able to accept XML of the following forms from a web service and deserialize them. Form 1: <results> <sample> <status>status message</status> <name>sample name</name> <igsn>unique identifier for this sample</igsn> </sample> </results> Form 2: <results> <sample name="sample name"> <valid code="InvalidSample">no</valid> <status>Not Saved</status> <error>error message</error> </sample> </results> Here's my class that I'm