xml-serialization

WCF XmlSerializer assembly not speeding up first request

I am generating proxy classes to a clients java webservice wsdls and xsd files with svcutil. The first call made to each service proxy class takes a very long time. I was hoping to speed this up by generating the XmlSerializers assembly myself (based on the article How to: Improve the Startup Time of WCF Client Applications using the Xml...

PHP - Is htmlentities() sufficient for creating xml-safe values?

I'm building an XML file from scratch and need to know if htmlentities() converts every character that could potentially break an XML file (and possibly UTF-8 data)? The values will be from a twitter/flickr feed, so I need to be sure! ...

Serialize a generic collection specifying element names for items in the collection

I have a simple class derived from a generic list of string as follows: [Serializable] [System.Xml.Serialization.XmlRoot("TestItems")] public class TemplateRoleCollection : List<string> { } when I serialize this, I get the following XML: <TestItems> <string>cat</string> <string>dog</string> <string>wolf</string> </TestItems> ...

Deserializing JSON in WCF throws xml errors in .Net 4.0

Hi there. I'm going slidely mad over here, maybe someone can help me figure out what's going on. I have a WCF service exposing a function using webinvoke, like so: [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, Respo...

MSMQ first Message.Body in queue is OK, all following Message.Body in queue are empty

I send a handful of identical (except for Id#, obviously) messages to an MSMQ queue on my local machine. The body of the messages is a serialized XElement object. When I try to process the first message in the queue, I am able to successfully de-serialize the Message.Body object and save it to file. However, when trying to process the ...

XmlSerializer Producing XML With No Namespace Prefix

I have to create an XML file with all the elements prefixed, like this: <ps:Request num="123" xmlns:ps="www.ladieda.com"> <ps:ClientId>5566</ps:ClientId> <ps:Request> When i serialize my object, c# is smart and does this: <Request num="123" xmlns="www.ladieda.com"> <ClientId>5566</ClientId> <Request> That is good, because the...

Control XML serialization of Dictionary<K, T>

I'm investigating about XML serialization, and since I use lot of dictionary, I would like to serialize them as well. I found the following solution for that (I'm quite proud of it! :) ). [XmlInclude(typeof(Foo))] public class XmlDictionary<TKey, TValue> { /// <summary> /// Key/value pair. /// </summary> public struct Di...

Serialization of an object and its Contained Objects

There is a main class having 2 subClasses(each represent separate entity) and all classes needs to be serialized.. how should I proceed ? My requirement is when I serelize MainClass, I should get the xml for each sub class and main class as well. Thanks in advance... and if my approach is incorrect... correct that as well.. Ex given ...

XML serialization and MS/Mono portability

I'm trying to have classes serialized using MS runtime and Mono runtime. While using MS runtime everything goes fine, but using Mono I give me some exception and program startup. The following exception are thrown: There was an error reflecting a type: System.TypeInitializationException (a class) There was an error reflecting a type: ...

Using XSD file in VS2005

Hello all I want to write an XML file. I have created an XSD file named XMLSchema.xsd, and run the command 'xsd /c XMLSchema.xsd' which generated a c# class file. Now, how do I use this file to generate XML files? Part of my code: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="XMLSchema" targetNamespace="http://tempuri.org/XM...

WCF: VS2010 confuses System.Xml.XmlElement with System.Xml.Linq.XElement?

I have created a WCF service with one method which returns a System.Xml.XmlElement: Interface: using System.Xml; ... [ServiceContract] public interface IWCFService { [OperationContract] XmlElement Execute(...); } Service: using System.Xml; ... public XmlElement Execute(...) { XmlNode node = ...; return (XmlEleme...

How can i use Xml Serilization with gridview?

i try to use xml serilization in gridview but it returns me: InvalidOperationException was unhandled by user code My code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Serialization; using System.IO; namespace WebAppl_seri...

XmlSerializer: The string '' is not a valid AllXsd value.

I'm getting this message,"The string '7/22/2006 12:00:00 AM' is not a valid AllXsd value.", when deserializing an XML, the element contains a date, this is the property that is supposed to be mapped to the element: [XmlElement("FEC_INICIO_REL",typeof(DateTime))] public DateTime? FechaInicioRelacion { get; set; } Am I doing something w...

How to implement type-change for XML serialized types?

I have a class that is serialized to XML. Inside, I have a member: private double? mDefaultMin = null; protected double? DefaultMin { get { return mDefaultMin; } set { mDefaultMin= value; } } Later on, I realize that I actually need to store list of values: private DoubleList mDefaultMin = null; protected DoubleList DefaultM...

XmlSerializer - Deserialize different elements as collection of same element

I have the following XML part which schema I can't change. NUMBER, REGION, MENTION, FEDERAL are columns: <COLUMNS LIST="20" PAGE="1" INDEX="reg_id"> <NUMBER WIDTH="3"/> <REGION WIDTH="60"/> <MENTION WIDTH="7"/> <FEDERAL WIDTH="30"/> </COLUMNS> I want to deserialize it to public List<Column> Columns {get;set;} property. So elem...

Do I have to worry about escaping XML reserved characters before I return a DataContract object from an OperationContract in WCF?

Hi, I am pretty inexperienced with WCF. I have a DataContract that implements the IExtensibleDataObject interface. Some of the members of this object are populated from freetext input and could contain XML reserved characters ('>', for example). I imagine that I get escaping of these characters for free with WCF, but I have been look...

C++ Serialization Clean XML Similar to XSTREAM

I need to write a linux c++ app which saves it settings in XML format (for easy hand editing) and also communicates with existing apps through XML messages over sockets and HTTP. Problem is that I haven't been able to find any intelligent libs to help me, I don't particular feel like writing DOM or SAX code just to write and read some ve...

Required attributes in XML serialization

For example I have class to serialize [Serializable] class Person { [XmlAttribute("name")] string Name {get;set;} } I need to make Name attribute required. How to do this in .NET? ...

Trigger function on deserialization

I have a class with a number of fields which are normally calculated in the constructor from other data in the class. They are not serialized to XML because any changes to the rest of the data will likely require their recalculation. Is there a way I can set up a function call to be triggered on deserialization? ...

How to serialize a data of type string without using StringWriter as input

I want to serialize a input data of type string, but do not want to use StringWriter and StringReader for for serializing/Deserializing. The reason for this is when a escapse chars are sent as part of the Input string for serializing, it is serialized but some Spl chars are inserted in the xml(eg:"").I'm getting an XMl error while deser...