xml-serialization

Design Pattern for XML Based Project Files in C#

I am developing a C# application where the majority of the code base is in C# class libraries. I want the application to support saving and loading of XML based project files and be able to determine if any modifications have occurred since the last save. My current design idea is: Each class that needs to store settings implements IX...

Naming XML Tags

This is not a technical question. More of a standardizing thing. I have a bunch of business objects that I need to serialize to XML. In its simplest form, I got object X holding objects of type Y. Y is extended to Y1, Y2, Y3. My question is, should I go with: <X> <Y> <Y1 /> <Y2 /> <Y1 /> <Y3 /> </Y> </X> or: <X> ...

Spring MVC: Adding JAXB to the classpath so that it automatically serializes XML

According to Spring MVC documentation, <mvc:annotation-driven/> configures support for JSON if Jackson is in the classpath, and support for XML if JAXB is present in the classpath. Simply by adding a Jackson dependency to my pom.xml, I get JSON support to work! (see: Ajax Simplification in Spring 3.0) However, after trying to access the...

Child Xml Element is not Deserializing

The Problem I have an issue when I deserialize my xml, one of the child elements is not being deserialized. It is null in the class instance despite being populated in the xml. A little Background I used XsdObjectGenerator to create poco classes based on my .xsd. I was then able to deserialize the xml into a class instance and wo...

Can XmlSerializer.Deserialize ever return null?

I ve been trying in a few different ways to get XmlSerializer.Deserialize to return null however it doesnt seem possible I tried with a class being null, malformated xml, well formatted xml . I might be missing something obvious here, but is it possible ? Just to clarify give a Class MyClass that is serializable I want a similar test ...

Serialization How to dynamicly ignore all members of a specific type

I want to ignore all elements of Dictionary while serializing as those members cause an exception example class: public class TestClass{ public string StringTest { get; set; } public int IntTest { get; set; } public Dictionary<int, string> someDictionary { get; set; } } What i tried(unsuccessfull) XmlAttributeOverrides x...

Serializer that sees private data, has parsable output, supports generic collections, and supports custom serialization

I need a very specific kind of .NET serializer. My requirements: shouldn't skip private data output should be human-readable (or at least, easily parsable), preferably XML should support generic collections (no need to be easy, but it should be possible) should support custom-implemented serialization for specific classes. I need (2...

Customizing XStream output

I have a class that resembles something like this: class foo { List<String> bar; ... } I add four Strings to the list bar: bar.add("1"); bar.add("2"); bar.add("3"); bar.add("4"); Using xstream, I've managed to get output that looks like this: <foo> <bar> <blah>1</blah> <blah>2</blah> <blah>3</blah> <b...

Ignore a parent class when Serializing to XML

Is there a JAXB annotation to ignore a parent class, when you have an @XmlElement on a List of the child classes? Just to clarify - I was wondering if there was a better way than marking all of the parent classes getters/setters as transient, and then having to go back to the child classes and add getters/setters and annotating those as...

Force DTD ignore when using WCF REST Starter Kit ReadAsXmlSerializable?

I'm using the WCF Rest Starter Kit, and I'm able to send and receive data. I'm trying to serialize the data I receive from the service, but for whatever reason, the XML reponse from the service includes (what I'm guessing is) an invalid DTD. For example: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE response> <response> // blah blah...

Xstream to map "choice" elements of XML

I need to map an XML, constrained by an XSD to Java object using XStream. The XSD has 4 complex type elements, which are "choice" elements, that is either one of those 4 can be present in the XML under a root tag. I have been looking at XStream but it seems to me that, to map such an XML, I would require 8 classes. How? here it is... S...

How do I serialize DOM into XML using PHP?

I am attempting to send html data in a question form from my php web application to mechanical turk so a user can see the entire html document from an email to work with. I have had difficulty thus far. In the thread linked below, I attempted to parse the html data using html5-lib.php, but I think I'm still missing a step in order to c...

Serialize class variable as xml without creating a new element

I have two classes, A and B. A has an instance of B, and when serializing A, I want B to be at the same level as A and not a sub element. So I want the resulting xml to become <a> <avalue>a</avalue> <bvalue>b</bvalue> </a> This program puts B in it's own element as <a> <avalue>a</avalue> <b> ...

LINQ to XML - how do I obtain index

I have an array of Car objects and using the following piece of code I create an XML Document from these objects. I have set up a counter variable i to be able to index the Car elements in the document. Is there a different way of obtaining the index of the currently processed element? int i = 0; XDocument doc = ...

WCF: Serialization? Streaming?

Hi guys, I need to understand how does WCF works when sending a message. Does WCF serialize everything before sending it? My other question is which will be the benefit of using Streaming? Is it better for bigger messages, lets say between 1Mb to 2Mb? Can I send a complex object serialized, and then be able to deserialize it in the oth...

Most elegant way to serialize an object with byte[] members to an XDocument?

I have a serialization utility that serializes an object to an XDocument. It works quite well : public static class SerializationUtil { public static T Deserialize<T>(XDocument doc) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); using (var reader = doc.Root.CreateReader()) { re...

ERROR errors.GrailsExceptionResolver - Cannot reference implicit element

I am getting the below error when I try to use Xstream to marshal one of my groovy domain classes Employee. Employee hasmany employeDesiredSkills, which belongsTo Skill and Employee Here is the relevant Xstream code employeeInstance = new Employee(); XStream xstream = new XStream(); Xstream.alias("employee", Employee.class); String x...

Silverlight application with binary xml

My silverlight + ASP.NET MVC application does the following: 1) Silverlight client sends request via HttpWebRequest. 2) ASP.NET MVC connects to a SQL Server database (stored procedure) and gets back XML data It then sends that raw xml to the client (no web services or WCF). 3) Silverlight client receives xml and deserializes it wit...

Deserializing XML into class obj in C#

This is one of the entries I have in a huge XML file of over 200 such entries. <TradeFills> <TradeFill> <Broker>xxx</Broker> <CustomerAccount/> <qwFillTransID>xxxxxxxxxxxxxxxxxxx</qwFillTransID> <qwPrevTransID>xxx</qwPrevTransID> <qwGroupTransID>xxxxxxxxxxxxxxxxx</qwGroupTransID> <GroupTransID>xxxxxxxx</GroupTransID> <Tra...

Having trouble deserializing XML file into class object

This is a sample of the XML file I am attempting to deserialize <TradeFills> <TradeFill> <Broker>xxx</Broker> <CustomerAccount/> <qwFillTransID>xxxxxxxxxxxxxxxxxxx</qwFillTransID> <qwPrevTransID>xxx</qwPrevTransID> <qwGroupTransID>xxxxxxxxxxxxxxxxx</qwGroupTransID> <GroupTransID>xxxxxxxx</GroupTransID> <TransID>x</TransID...