xml-serialization

How to encrypt a serialized XML and store in registry

I'm trying to encrypt a serialized XML document and store it in the registry. I was wondering on how to accomplish that? I am able to store a non-serialized XML document in the registry by converting the XMLdoc to a byte array, but I'm not sure on how to do it for a serialized XML. My XML serialization example: using System.Xml.Seria...

Prevent timezone conversion on deserialization of DateTime value

I have a class that I serialize/deserialize using XmlSerializer. This class contains a DateTime field. When serialized, the DateTime field is represented by a string that includes the offset from GMT, e.g 2010-05-05T09:13:45-05:00. When deserialized, these times are converted to the local time of the machine performing the deserializa...

Combine a serialized object with an existing xml doc and return it?

Hello, I'm trying to figure out to to combine a serialized object with an existing xml doc and return it as a webservice. Thanks ahead for you help. Sample code: [WebMethod] public string GetApple() { Apples apples = Report.GetReport(); // this returns: // <Apples xmlns:xsi="http://www.w3.org/2001/XMLSchema-...

Error while deserializing XML from SQL Server

I have an application which serializes and deserializes .NET objects to XML. While deserializing I am getting the following error: "There is an error in XML Document(1,2) Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 2. " The code snippet that does the deserializing is: string xmlEntity ...

XML Serialization in C#

Hello, Where Can I find good tutorial about XMl serialization to the object? Thanks. ...

XML Serialize instead of JSON in .NET

Is there a way to fill out a class using XML data instead of JSON? Example in marc's excellent answer. I would like everything to be as close to that code except the input is an xml file instead of json. ...

how to deserialize this xml in Silverlight

Xml is here <?xml version="1.0" encoding="utf-8"?> <s> <Items> <b name="test" width="100"> <Items> <d x="1"/> <e width="50"/> </Items> </b> <b name="test2" width="200"> <Items> <d x="2"/> </Items> </b> </Items> </s> I'm creating those classes public class s { public s(){ Items=...

Xml Deserializer to deserialize any data type

Because I haven't found a better way to handle my configuration, I have been using XmlSerializer to serialize a Dictionary (explain that later) containing all the things I want saved. Now that I have gotten more crafty, I have started to build more complex data types. The only problem is that now when I serialize the object, it throws an...

When to use XamlWriter.Save() to serialize domain object?

What's the rationale (if any) of using XamlWriter.Save() to serialize a domain object? Please describe realistic scenarios. Thanks. ...

xstream flatten an object

Hello, I am trying to flatten the xml output of xstream using a converter/marshaling with no luck. For example, public class A{ public B b; public int F; public String G; } public class B{ public String C; public String D; public int E; } is output as <A> <B> <C></C> <D></D> <E></E> </B> ...

Logging xml data in an xml log file...

I am needing to log some xml data (which is currently a JDOM Document), and I am trying to output it to a standard Java log. However, this will only produce logs with the < and > ends of the tags re-encoded as &lt;? ?&gt; etc. Although this can be parsed for the right information, it makes the log file effectively unreadable. Can an...

XML Serialization - handling special cases

I need to XML serialize some classes, which in some cases do not adhere to the rules and guidelines, that is needed in order to make built-in serialization work. This includes properties that are interface types and properties without setters. I know how to implement IXmlSerializable, but it could be a lot of work; since most of the pr...

DataContractSerializer - how can I output the xml to a string (as opposed to a file)

Hi All, I had a quick question regarding the datacontractserializer. Maybe it's more of a stream question. I found a piece of code that writes the xml to a filestream. I basically don't want the file and just need the string output. public static string DataContractSerializeObject<T>(T objectToSerialize) { var fs = new ...

Can you use other formats beside XML with XMLHttpRequest?

I understand JSON can be used instead of XMLHttpRequest in Javascript, but can I make requests and get totally arbitrary data back? Like a custom text or binary format? Or is the interface limited to jSON and XML? I hope I get through what I wonder here... a) How do I create a plain request without XML or JSON? b) How do I access ...

Indentation issues with Staxmate API

I am using Staxmate API to generate XML file. After reading the tutorial: http://staxmate.codehaus.org/Tutorial I tried making the changes in my code. At last I added the call doc.setIndentation("\n ", 1, 1); Which causes the newly generated XML file to be empty! Without this method call entire XML file gets generated as expected. ...

When should XML serialization be used?

I've been doing some reading up on XML serialization, and from what I understand, It is a way to take an object and persist the state in a file. As for the implementation, it looks straight forward enough, and there seems to be a load of resources for applying it. When should XML serialization be used? What are the benefits? What are sit...

Simple, structurally typed XML data binding (without code generation or reflection)

I'm looking for a Java library that would allow me to marshal XML to a Java object tree, and vice versa. There are plenty of libraries that would allow me to bind XML to JavaBeans generated by some code generation tool, however, I don't need those (JAXB, JiBX, Castor and so on). What I need is a tool which would consume a schema file a...

How to PROPERLY remove xmln:xsi and xmlns:xsd from xml dictionary serialization

Question: I use a serializable dictionary class, found at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx , to serialize a dictionary. It works fine with the example class below. <System.Xml.Serialization.XmlRoot("ccl")> _ Public Class ccl <System.Xml.Serialization.XmlElement("name")> _ Public xx As String = ""...

Serializable dictionary, how to set key name ?

Question: I use a serializable dictionary class, found at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx , to serialize a dictionary. Which works fine, but I run into an annoying problem. <System.Xml.Serialization.XmlRoot("DataBase")> _ Public Class cDataBase <System.Xml.Serialization.XmlNamespaceDecl...

Serialize xmls element attributes to properties of child object.

Hello, I've following xml element: <point X="-1368.087158" Y="-918.482910" Z="156.191040" nX="0.241530" nY="-0.945819" nZ="0.217001"/> and following object structure: public class Point { [XmlAttribute("X")] public float X { get; set; } [XmlAttribute("Y")] public float Y { get; set; } [XmlAttribute("Z")] publ...