xml-serialization

groovy.xml.MarkupBuilder disable PrettyPrint

I'm using groovy.xml.MarkupBuilder to create XML response but it creates prettyprinted result which is unneeded in production. def writer = new StringWriter() def xml = new MarkupBuilder(writer) def cities = cityApiService.list(params) xml.methodResponse() { resultStatus() { r...

How to customize serialization of List<string> in C#

This is killing me. I've read these: http://msdn.microsoft.com/en-us/library/athddy89(v=VS.80).aspx http://msdn.microsoft.com/en-us/library/2baksw0z(v=VS.80).aspx But I don't see how to apply them to what I'm trying to do. I want to customize the way the following list serializes... [Serializable] public class FinalConcentrations :...

Serializing objects which implement IEnumerable<>, using XmlSerializer

Hi, I'm trying to serialize an object which contains an object which implements IEnumerable<>. The last object also contains an object which implements IEnumerable<>. The objects strucutre is as followed: [Serializable] public class A { public B _b {get; set; } } [Serializable] public class B : IEnumerable<C> { public Lis...

Most elegant xml serialization of Color structure

One problem bugged me enough to register on stackoverflow. Currently if I want to serialize Color to XML string as named color, or #rrggbb, or #aarrggbb, i do it like this: [XmlIgnore()] public Color color; [XmlElement(ElementName = "Color")] public String color_XmlSurrogate { get { return MyColorConverter.SetColor(color); } set { ...

Serialization across projects with inheritance

I have a base class ("MyBaseClass") in a project called "BaseFramework" which is included in several solutions within the company. There are several derived class's in various projects throughout the company that inherit from "MyBaseClass". If I then create a List and add derived class's to it, it will not serialize. I realise that if I...

Serialize/deserialize objects - order of fields matters?

Is it possible that DataContractSerializer wrongly deserializes object if fields are not in the "correct" (whatever that means) order? My classes that I serialize/deserialize do not have order attributes placed on fields/properties. Yet one of my fields always get deserialized as null although it has values, it actually contains a list o...

C# generic serialization utility class

I have an existing class for serializing and deserializing objects to/from XML. It's a generic class with a single type parameter T whose only constraint is where T : IXmlSerializable. However, I want to still be able to use this class on classes that do not implement IXmlSerializable but have the [Serializable] attribute. How could I...

Object serialization in XML format using Obj-C / iPhone SDK

Hi folks, I have an iPhone App that uses a relatively small amount of data. I'd like to save the data in the XML format and be able to load this in memory to Objective-C objects. I'd like to use iPhone SDK facilities like NSPropertyListSerialization or writeToFile:atomically: classes and methods. The NSPropertyListSerialization documen...

XML to/from a Python dictionary

I need to use Python 2.4.4 to convert XML to and from a Python dictionary. All I need are the node names and values, I'm not worried about attributes because the XML I'm parsing doesn't have any. I can't use ElementTree because that isn't available for 2.4.4, and I can't use 3rd party libraries due to my work environment. What's the easi...

serializing an RSAKeyValue property in Serializable class

I have a class in my C# project marked with the [Serializable] attribute. It has a property of type RSAKeyValue: [XmlElement(PUBLIC_KEY_TAG_NAME)] public RSAKeyValue Key { get; private set; } When I try to serialize an instance of my class to XML and then deserialize that XML back to an instance of my class, I get: System.Invalid...

Getting a xml error on live site but not local host.

Hi I have some XML Serialization and it works on my local machine but when I put it up on my hosting company and try it out it fails. I don't know why Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Plea...

web service serialization problem

hi there, I have a web service. A method of this web service, returns WSSonuc class. [Serializable] public class WSSonuc { public int M_Durum { get; set; } public object M_SonucNesne { get; set; } } this is my Web service method: [WebMethod] [SoapHeader("_ticket", Direction = SoapHeaderDirection.InOut)] public WSSonuc f...

What is the quickest way to serialize a Java object to Map (and parse back) with minimum code writing?

Hi guys, I have a system that entities (from database, represented as Java objects through ORM) will be read by XML-RPC clients, my existing way is to serialize them via a StructSerializer, which in its code, we read properties out from the Java object, including calling another StructSerializer to serialize/parse a property, e.g. Surr...

What is the best object to string XML serialization API for Java 1.4?

I want to generate a XML String for a given object. What is the best API to serialize an object to XML String using Java 1.4? Thanks, RT ...

XSD .net code gen + alternative serialization methods

I'm having a time deciding on a direction to go with a class lib I'm building. I have a batch of industry standard XSD's, from which I'm generating .net objects. I;ve used all of XSD.exe, LinqtoXsd, xsd2code, and even OxmLibrary with varying results. But in the end, I am able to generate decent .net classes which can be serialized/dese...

Serializing Object - Replacing Values

Hey Everyone, I've got a collection of around 20,000 objects that need to get persisted to my database. Now, instead of doing 20,000 insert statements, I want to pass all the records in using an XML parameter. As far as serializing the object and passing it into the procedure goes, I'm all set. However, I'm wondering if anyone has an...

Better way to create XMLs at Runtime

I am working on an Android application that is required to connect to a REST WebService. There are a number of requests that the application needs to make and the request format is XML. What I have done presently is create a Request template per XML request using StringBuilder class and substitute a placeholder String for different value...

using XmlArrayItem attribute without XmlArray on Serializable C# class

I want XML in the following format: <configuration><!-- Only one configuration node --> <logging>...</logging><!-- Only one logging node --> <credentials>...</credentials><!-- One or more credentials nodes --> <credentials>...</credentials> </configuration> I'm trying to create a class Configuration that has the [Serializable] a...

.NET Xml Serialization: Integer Element with Attribute?

Is it possible to achieve the following in c#... for the class below... public class Foo{ public int BarId{get;set;} public string BarString{get;set;} } I want to achieve the following XML: <Foo> <BarId BarString="something">123</BarId> </Foo> ...

Remove whitespaces in XML string

How can I remove the whitespaces and line breaks in an XML string in Python 2.6? I tried the following packages: etree: This snippet keeps the original whitespaces: xmlStr = '''<root> <head></head> <content></content> </root>''' xmlElement = xml.etree.ElementTree.XML(xmlStr) xmlStr = xml.etree.ElementTree.tostring(xmlElement, ...