xml-deserialization

C# XML Deserializing Error (2,2)

北城余情 提交于 2019-12-23 18:35:33
问题 School gave me an XML document, and I have to display the information on a screen. As far as I know, Xml Deserialization would be the easiest/nicest solution. I have this so far: public static List<Project> ProjectListDeserialize(string path) { XmlSerializer serializer = new XmlSerializer(typeof(List<Project>)); Stream filestream = new FileStream(path, FileMode.Open); return (List<Project>)serializer.Deserialize(filestream); } public static Projects ProjectsDeserialize(string path) {

WebAPI 2.0 Post Not Deserializing List<T> Property

冷暖自知 提交于 2019-12-23 16:23:51
问题 I have reviewed every similar article I can find here and tried anything that looked like it might work with no success (obv since I am now asking the question). I have a webAPI 2.0 controller with a POST action that takes in an object of type Reservation . This object contains, among other things, a property called Items which is of type EquipmentItems . As you can imagine, this is a List property. I send the reservation object over (using PostAsJsonAsync("api/Reservation", reservation)

Deserialization not filling data - C#

跟風遠走 提交于 2019-12-23 13:26:16
问题 I am trying to deserialize an XML . Sample XML is given below <?xml version="1.0" ?> <TRANSACTION_RESPONSE> <TRANSACTION> <TRANSACTION_ID>25429</TRANSACTION_ID> <MERCHANT_ACC_NO>02700701354375000964</MERCHANT_ACC_NO> <TXN_STATUS>F</TXN_STATUS> <TXN_SIGNATURE>a16af68d4c3e2280e44bd7c2c23f2af6cb1f0e5a28c266ea741608e72b1a5e4224da5b975909cc43c53b6c0f7f1bbf0820269caa3e350dd1812484edc499b279</TXN_SIGNATURE> <TXN_SIGNATURE2

SQL Cursor throws out of memory while calling getString

余生颓废 提交于 2019-12-23 12:56:26
问题 Attachment Reference to my earlier question :- Out of memory I would try to be as precise as possible. I am getting a response from my web-service call a long base64 string. I decode the string and get a huge string which contains my data. I de-serialize the string and create the object of my class using the string as below. String decryptedXml = XmlObject.toDecryptedXmlString(gameDetail.getGameData(), app.getSessionEncryptionKey()); Game noviceGame = deserialiseGame(decryptedXml, NoviceGamer

Perl deserialize XML

北慕城南 提交于 2019-12-23 04:08:07
问题 I have XML file (output of some application) like this: <data> <call function="get_user_data"> <output> <integer name="my_id" value="-31" /> <string name="login" value="root" /> <integer name="ip_list" value="2" /> <array name="i"> <item> <ip_address name="user_ip" value="0.0.0.0" /> <ip_address name="user_mask" value="0.0.0.0"/> </item> <item> <ip_address name="user_ip" value="94.230.160.230" /> <ip_address name="user_mask" value="255.255.255.0"/> </item> </array> <integer name="modules"

Deserialization from XML to List Object

筅森魡賤 提交于 2019-12-23 04:04:49
问题 I am doing the program in convert XML file to List Objects. I have successfully done serialization from List to XML .but I have an problem on doing deserialization. Please anyone tell me what's the wrong i have done in this code. This is my XML code. <?xml version="1.0"?> <Contact_x0020_Form xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Contact> <Contact> <Id>1</Id> <Name>vicky1kumar</Name> <Phone>248847227</Phone> </Contact> <Contact>

XmlSerialization with a singleton

无人久伴 提交于 2019-12-23 00:26:43
问题 Serialization woes continue... I'm trying to serialize a class, instances of which share between them common objects (a binder of sorts). So, objects A, B, C share object Binder1, and objects D and E - Binder2, and so on... I'm serializing objects A,B,C,D,E. Typically, this binder object is passed in a constructor - not with the serializer though, since it needs a parameterless constructor. ISeriazable seems to have something that works for singletons - IObjectReference interface, where the

Cannot parse simple XML into an object?

岁酱吖の 提交于 2019-12-23 00:22:51
问题 XML <MeterWalkOrder> <Name>Red Route</Name> <Meters> <Meter> <MeterID>1</MeterID> <SerialNumber>12345</SerialNumber> </Meter> <Meter> <MeterID>2</MeterID> <SerialNumber>SE</SerialNumber> </Meter> </Meters> </MeterWalkOrder> I cannot get simple XML into an object using any serializer var xml = File.ReadAllText("WalkOrder.xml"); var xmlSerializer = new NFormats.Xml.XmlSerializer(); var obj = xmlSerializer.Deserialize<MeterWalkOrder>(new StringReader(xml)); I just get back 2 meter objects that

require either one element or the other in JAXB

浪尽此生 提交于 2019-12-22 14:38:14
问题 I have a JAXB-annotated POJO like this: @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Clazz implements Serializable { @XmlElement(required = false) private int a; @XmlElement(required = false) private int b; } I want to mark that either field a or field b is required. With my current set-up, none of them are required, but I want one of them to be present and not the other. How could I achieve it? 回答1: You can do the following with @XmlElementRefs Domain Model Clazz import

Cannot deserialize with XMLSerializer result from WCF webservice

限于喜欢 提交于 2019-12-22 06:56:12
问题 Here is the code trying from compact framework to get http service.. List<Table> tables; using (Stream r = response.GetResponseStream()) { XmlSerializer serializer = new XmlSerializer(typeof(Table),"http://schemas.datacontract.org/2004/07/"); tables=(List<Table>) serializer.Deserialize(r); } response.Close(); It fails with {"There is an error in XML document (1, 2)."} {"<ArrayOfTable xmlns='http://schemas.datacontract.org/2004/07/WpfApplication1.Data.Model'> was not expected."} Table