I have code using XmlSerializer to serialize/deserialize a data structure for persistance. I've read and heard in several places here on StackOverflow that XmlSerializer is one or more of:
Bad
Poorly supported/implemented
Possibly won't be supported into the future
My question is two-fold; is any of the above true, and if so, what al...
I have some web methods that return my objects back as serialized XML. It is only serializing the NHibernate-mapped properties of the object... anyone have some insight? It seems to be that the web methods are actually serializing the NHibernate proxies instead of my classes. I've tried using [XMLInclude] and [XMLElement], but the pro...
When a typed DataSet is written to XML using ds.GetXml the columns with null values are removed from the XML. I know this is because the schema is not written etc. but is there a way to override this without having to parse through the DataSet and convert all database nulls to empty string before writing the XML?
EDIT: additional info...
The Xml response I receive is as follows:
<response>
<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:com.someDomain.item">
<name>some name</disc-name>
<description>some description</disc-desc>
</item>
<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:com.someDomai...
It seems that sgen.exe could not generate generic type XmlSerializer, right?
My genereic type:
[Serializable]
[XmlRoot(ElementName = "Masterx")]
public class Masterx<T> where T : class, new()
{....}
Serializer code:
protected virtual List<T> ParseXMLToObject<T>(string resultXML) where T : class, new()
{
//return ParseXM...
I'm trying to deserialize the XML below into class, with the "Components" deserialized into a List of type String, but can't figure out how to do so. The deserializer is working fine for all the other properties, but not "Components". Anyone know how to do this?
<ArsAction>
<CustomerName>Joe Smith</CustomerName>
<LoginID>jdsmith</...
I'm writing a plug-in for an application where I have a custom class that attributes the native objects of the program. The API allows me to read and write keyed strings directly to and from the objects in the native file. So rather then reading and writing to private fields in the Get and Set accessors of each property I'm reading and w...
Can I serialize a generic list of serializable objects without having to specify their type.
Something like the intention behind the broken code below:
List<ISerializable> serializableList = new List<ISerializable>();
XmlSerializer xmlSerializer = new XmlSerializer(serializableList.GetType());
serializableList.Add((ISerializable)Pers...
In my XSD, I have something similar to this:
<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:jump="testThingy" elementFormDefault="qualified" targetNamespace="testThingy" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="command" type="jump:commandType" />
<complexType name="loginType">
<sequence>
<element ...
I'm trying to serialize a class that derives from BindingList(Floor), where Floor is a simple class that only contains a property Floor.Height
Here's a simplified version of my class
[Serializable]
[XmlRoot(ElementName = "CustomBindingList")]
public class CustomBindingList:BindingList<Floor>
{
[XmlAttribute("publicField")]
publ...
Hello everyone,
I am using C# + VSTS2008 + .Net 3.0 to do XML serialization. The code works fine. Here below is my code and current serialized XML results.
Now I want to add two additional layers to the output XML file. Here is my expected XML results. Any easy way to do this? I am not sure whether NestingLevel could help to do this. I...
I am using VSTS2008 + C# + .Net 3.0. I am using below code to serialize XML, and my object contains array type property, but there some additional elements' layer (in my sample, MyInnerObject and MyObject) generated which I want to remove from the generated XML file. Any ideas?
Current generated XML file,
<?xml version="1.0"?>
<MyClass...
Hello everyone,
I am using VSTS2008 + C# + .Net 3.0. I am using below code to serialize XML, and my object contains array type property, and I want to add an additional elements' layer ("MyInnerObjectProperties" element layer in my expected results below, and I want to make "MyInnerObjectProperties" element as parent element for all My...
I am using VSTS2008 + C# + .Net 3.0. I am using below code to serialize XML, here is my current code and serialized XML file. My purpose is I want to make MyInnerObjectProperties belongs to a special XML namespace (http://foo/2009) and making this namespace as default namespace. Any ideas how to implement this?
Current output:
<?xml ve...
I am trying to serialize an array and want to attach an attribute to the array. For example, the output I want is:
<ArrayOfThingie version="1.0">
<Thingie>
<name>one</name>
</Thingie>
<Thingie>
<name>two</name>
</Thingie>
</ArrayOfThingie>
This is just a primitive array, so I don't want to define the attribute for the ...
I want to serialize DateTime so that when DateTime is null I dont get the tag itself.
I have also set bool specified for the above but my problem is DateTime being of value type it will never be null hence the bool specified will always be true for it.
I even tried replacing DateTime to System.Nullable but I get Serialization Error whe...
First question on Stackoverflow (.Net 2.0):
So I am trying to return an XML of a List with the following:
public XmlDocument GetEntityXml()
{
StringWriter stringWriter = new StringWriter();
XmlDocument xmlDoc = new XmlDocument();
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);...
How do I cast an instance of an object and actually make it that type of object?
I have a class myClass1 that is the base class for myClass2 and myClass3. I want to use myClass1 for auditing, for auditing all I want is the data from myClass1. Because myClass2 and myClass3 inherit from myClass1 you can set an instance of myClass1 to an...
When i run the following code to serialize the facbook users, the code generated is something like:
<?xml version="1.0"?>
<ArrayOfUser
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="fbapp">
<user>
<user xmlns="http://api.facebook.com/1.0/">
...
I'm trying to render a large (ish) array of objects as a plist in Ruby on Rails. The collection currently contains up to 200 objects, each of which is essentially a record (dictionary of keys/values). The overall result format is a plist (as used by Apple) but logically it is not much different from any XML document.
The problem I've hi...