xml-serialization

C# XML Serialization Problem

I have created a method that accepts an object then attempts to serialize the object to Xml by first using the XmlSerializer to serialize to a string, then load the Xml back into an XmlDocument object for the method to return. The code looks like this; public static XmlDocument ConvertObjectToXMLMessage(object ObjectToConvert) { ...

Tool that can combine many XSD files into one?

I need to create XML serializer classes for approximately 65 XSD files, for which I am using Microsoft's XSD.EXE to generate the C# code... However, I keep running into Window CMD's character limit in the resulting output file (in which XSD.EXE combines the name of every XSD included): "The specified path, file name, or both are too lon...

Serializing an object as UTF-8 XML in .NET

Proper object disposal removed for brevity but I'm shocked if this is the simplest way to encode an object as UTF-8 in memory. There has to be an easier way doesn't there? var serializer = new XmlSerializer(typeof(SomeSerializableObject)); var memoryStream = new MemoryStream(); var streamWriter = new StreamWriter(memoryStream, System.T...

Custom property serialization

Hello, I have a class that contains a list of objects, say a list of cars : class Garage { public virtual List<Car> cars { get; set; } } The reason I can't directly serialize this list is that the type Car could have a lot of subclasses, and themselves could have other subclasses, and I'd like to avoid upd...

NServiceBus Xml Serialization issue with messages that have an IEnumerable<T> property

Hi, I'm trying to send a message with an IEnumerable property, am i correct that the NServiceBus Xml serializer cannot support this ? If i switch to using an array rather than IEnumerable it will work, if i use the binary serializer it also works My message look like this [Serializable] public class Parent : IMessage { public string...

Serialize XML where elements differ only by rel="

I'm trying to serialize some XML. Normally, I would just create a class and use the System.Xml.Serialization.XmlSerializer however, in this case there are various issues like the a few link tags that are only different because of the rel='. And so, I'm not sure how to serialize it and create the class for that. Any ideas? Here's a sam...

How to create xml file from a list of objects

I defined 3 classes: public class PublishedPage { public string Action { get; private set; } public string PageGuid { get; set; } public List<string> SearchableProperties { get; set; } public PublishedPage() { Action = "Published"; SearchableProperties = new List<string>(); } } public class Dele...

Changing inherited class name in XML C#

I am serializing a set of classes that looks like: public class Wrapper { IInterface obj; } public interface IInterface { } [XmlType("ClassA")] public ImplA : IInterface { } Currently the XML generated looks like <Wrapper> <IInterface xsi:type="ClassA"> ... </IInterface> </Wrapper> Is there anyway to include the custo...

XElement not declared when using Service Reference Proxy with XmlAnyElementAttribute

I am working on a Windows Phone 7 app that talks to a 3rd party Soap service. I used 'Add Service Reference' to the wsdl to generate the proxy class. Some calls work, but certain outbound calls that make use of an 'sObject' class result in the error "The type System.Xml.Linq.XElement was not expected. Use the XmlInclude or SoapInclude at...

SGEN error "Strong name validation failed."

Hi, I've been trying to use sgen.exe to genererate serialization assembly for my strong name signed assembly. I tried various set of parameters for sgen, but all my attempts ended with this error: SGEN: error SGEN1: Could not load file or assembly MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of i...

Use GraphML or GXL for Graphviz Graph output?

I'm seeding a discussion for an XML representation of Graphviz DOT output. Specifically, the extensions to xdot are proving difficult to parse as more are added and I think it's time for an XML option. Is GraphML or GXL the dominant form? The Wikipedia page on GXL suggests it has a stronger academic background for exchange of graphs. T...

.NET: Posting Xml to a web-server?

What is the proper way to post an XmlDocument to a web-server? Here is the skeleton function: public static void PostXml(XmlDocument doc, String url) { //TODO: write this } Right now i use: //Warning: Do not use this PostXml implmentation //It doesn't adjust the Xml to match the encoding used by WebClient public static void Po...

VB.Net Serialize anonymous type to xml

In MVC I can do something like the following to serialise an object with an anonymous type to JSON... Public Function GetStateList() As JsonResult Dim MyObject = New With {.Id = 1, .Property = "SomeValue"} Return Me.Json(MyObject) End Function which would return something like; { "Id": 1, "Property"Som...

XML serialization of enums

Hi, I have problems with serializing enum values. Here is the code: [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)] public class REQUEST { [System.Xml.Serialization.XmlAttributeAttribute()] public string ID; [System.Xml.Serialization.XmlAttributeAttribute()] public REQUESTTypetype Type; ...

XmlSerializer: "The type 'Type' may not be used in this context"

I'm trying to figure out how to serialize any class using the XmlSerializer, without using the XmlInclude attribute. Generally works, but with the following code I get an exception: using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.X...

How many variables point to the object and which [.net]

I want to make my own xml-serializer class because I need other formatting than the System.Xml.Serialization.XmlSerializer does. My idea is to treat properties of primitive type (such as Integer, Double, String) as XmlAttributes. To properly implement a usable Xml-Serialization I need to know which variables point to the same object (th...

Cocoa Touch: are dynamically XML-defined views possible?

Hi all, first post. Been an iPhone developer intern for about five weeks now. I've read a lot of introductory Apress material, but please take it easy if I make some vocabulary violations. So far I've been able to find answers by searching and lurking. However I now have a task for which I can find little relevant information. My iPhone...

Generate two different xml serializations for a .net class

I have a set of .net classes that I currently serialize and use with a bunch of other code, so the format of that xml is relatively fixed (format #1). I need to generate xml in another format (format #2) that's a pretty similar structure but not exactly the same, and am wondering the best approach for this. For example, say these are m...

Possible xml deserialization bug

I'm using the following xml schema entry to deserliaze some xml into an xsd generated block. <xs:element name="Action"> <xs:complexType> <xs:attribute name="src" type="xs:string" use="required" /> <xs:attribute name="dst" type="xs:string" use="required" /> <xs:attribute name="create" type="xs:string" use="optional" /> <x...

How to control Wcf REST XmlSerialization output.

I am trying to control the Xml output during a Wcf Rest serialisation process. I want to lose a tier in the output hierarchy. (I.e. lose the <content> tags). I have looked through the various attribute settings available, but not managed to find what I'm looking for. Can anyone help? My output is currently: <?xml version="1.0" encodi...