xml-serialization

how to show image inside xml

Hi, I have a class containing: [Serializable] public class ClsStatus { public byte[] Image { get; set; } public string Status { get; set; } public List<string> Servers { get; set; } } Now i am doing: System.Drawing.Image image = null; byte[] imageBytes = null; // Create an image of the chart. ...

convert text xml to binary xml in .NET 4

Is there any way to do that in .NET 4, may be with XmlDictionaryWriter? ...

Jaxb2Marshaller and attributes

I have a problem using Jaxb2Marshaller for unmarshalling XML attributes (of primitive types). Here is the sample: <?xml version="1.0" encoding="UTF-8"?> <request xmlns="..."> <items> <item id="1"/> <item id="2"/> <item id="3"/> </items> </request> And the entity class is: @XmlAccessorType(XmlAccessType...

Xml serialization appending the \0 (backslash 0 or Null) character?

I am trying to serialize an object and the \0 (Null) character is being appended to the generated string. Why? My code: XmlSerializer serializer = new XmlSerializer(typeof(Common.PlanogramSearchOptions)); MemoryStream memStream = new MemoryStream(); serializer.Serialize(memStream, searchOptions); string xml = Encoding.UTF8.GetStr...

Using Castor for Single Value classes

I have some XML to ingest that is set up like this <project> <client>Some client</client> <description>some description</description> </project> The Objects I need to unmarshal this data to are Project and Client. How do I set up my castor mapping for this? <class name="Project"> <field name="description" type="string" /> ...

Xml serialization. Deserialize and convert to a different object.

I have class: public class MyClass { [XmlElement("Date")] public DateTime Date { get; set; } } It was XML serialized to a file: var myClass = new MyClass() { Date = new DateTime(2010, 09, 24) }; new XmlSerializer(typeof(MyClass)).Serialize(fileStream, myClass); The result: <MyClass> <Date>2010-09-24T00:00:00</Date> </M...

Problem while hash table serialization using datacontract

Hi, I am trying to serialize a hash table using the link XML serialization of hash table(C#3.0) But I am receiving the error as Type 'WpfApplication3.MyHashtable' with data contract name 'AllMyHashtable:http://schemas.datacontract.org/2004/07/WpfApplication3' is not expected. Add any types not known statically to the list of known ty...

XML Serialization - Efficient?

Hey everybody. I'm creating a catalog app where users add/download information on cars. This could result in hundreds, possibly thousands, of cars and their data (make, model, year, image etc...). Seeing as WP7 no database, I'm using XML. My question is, would it be efficient to store every object in a list, then serialize that entire li...

Why is XmlSerializer.Deserialize throwing a System.IO.FileLoadException?

I'm having a problem with XML deserialization that is baffling me. I'm building an application that supports local customization of various services that it uses. I've implemented an abstract ServiceLocator class whose methods return various objects. Each custom installation is responsible for implementing a subclass of this and provi...

How to change the tag name of the serialized XML element via IXmlSerializable

Some background: We have some entity classes need to be serialized, so we implement the entity class as following in the first edition: [XmlType("FooElement")] public class Foo { [XmlText] public string Text { get; set; } } The serialized XML string should be: <?xml version="1.0" encoding="gb2312"?> <FooElement xmlns:xsi="ht...

Serialize type in x64 assembly to XML

I have a .dll that is compiled for 64bit, containing a class which I can serialize to XML. The library is compiled in Visual Studio using the "AnyCPU" flag. I have another process that is referencing that .dll, creating an object of that type then attempting to serialize it to XML like this: XmlSerializer serializer = new XmlSerializer...

Soap - Element doesn't have xsi:nil as a property, but deserializing doesn't make the object not null

I'm a total noob when it comes to XML and SOAP messages. ...Here's the SOAP message. <?xml version="1.0" encoding="utf-8" ?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <CR> <...

Delphi DeHL Deserialize XML File in newer class ?

Hi all, I use DeHL to serilize XML and class in Delphi and if add property to my class and try to deserialize my XML file. I have this error : ‘Deserializing « \TApp\FObject\test » failed. Serializer reported it’s missing or other entity is currently read!’. I understand quite well this problem but is there a way to put default value i...

GData Workspace Document

I have an application that currently uses Apache Abdera to parse Atom Pub documents (Workspace, Collection, Feed, Entry) - and want to switch the the GData Libraries, mainly to get rid of a lot of dependencies and I have found the GData calls to be consistently faster. Anyway, I cannot figure out how to generate some of these document t...

xml serialization specify xmlelement and xmlattribute together

Given :- [XmlRoot("Book")] public class Book { [XmlAttribute] public string Title; [XmlElement] public string Publisher; [XmlElement] public string PublisherReference; } When serialized to XML will give <Book Title="My Book"> <Publisher>Some Publisher</Publisher> <PublisherReference>XYZ123</PublisherReferenc...

WCF with XmlSerializer: namespace collision when returning generic contracts

The background I'm developing a REST API for a C#.NET web application using WCF. I configured it to use the XmlSerializer rather than its default DataContractSerializer, for greater control over the XML format. I created a generic ResponseContract<TResponse, TErrorCode> data contract, which wraps the response with <Api> and <Response> f...

MEF get implementors for a type known only at runtime

Hi, I'm using MEF and XML serialisation in my application. To put my question simply can i write a static class with a function like this: public static List<Type> GetImplementations(Type type, AggregateCatalog catalog) { ??? (type is an abstract class) } The back story: I use MEF to enable third party pluggins, however i want t...

Serialize class's ToString() value as XmlElement

In C#, I'm trying to serialize ClassA into XML: [Serializable] public ClassA { [XmlElement] public string PropertyA { get; set; } // works fine [XmlElement] public ClassB MyClassB { get; set; } } [Serializable] public ClassB { private string _value; public override string ToString() { return _valu...

Using IList<T> with NHibernate using Server 2008 64Bit

Hi, I have a class that one of its members defined like this : [DataMember] public virtual IList<T> RelatedXs { get { return this.m_relatedXs; } private set { this.m_related = value; } } But when I try to Save it using NHb Session object, I get this exception : "Cannot serialize member Rela...

Can I zero-pad an integer in an XSD-generated class?

Here's the situation: I have a client who's issued me an XML schema, and my software converts their records from tab-delimited to XML. One of those fields, "file-sequence," is typed as an integer in the schema. However, the client's client (the integration target) wants that integer zero-padded and 4 digits long (EG, <file-sequence>0001...