xml-serialization

Getting an invalidoperationexception when deserialising XML

Hi, I'm writing a simple proof of concept application to load up an XML file and depending on the very simple code, create a window and put something into it (it's for a much larger project). Due to limitations in Mono, I'm having to run in this way. The code I currently have looks like this using System; using System.Collections.Gene...

xerces serialization in Java 6

In Java 6, the entire xerces XML parser/serializer implementation is now in the Java runtime (rt.jar). The packages have been moved under the com.sun.* namespace, which places them off-limits for explicit reference within client code. This is not a problem when using the parser, which is instantiated via javax API-defined factories. ...

Why won't MSMQ send a space character?

I'm exploring MSMQ services, and I wrote a simple console client-server application that sends each of the client's keystrokes to the server. Whenever hit a control character (DEL, ESC, INS, etc) the server understandably throws an error. However, whenever I type a space character, the server receives the packet but doesn't throw an erro...

In .NET Xml Serialization, is it possible to serialize a class with an enum property with different tags based on property value?

I have a class, containing a list property, where the list contains objects that has an enum property. When I serialize this, it looks like this: <?xml version="1.0" encoding="ibm850"?> <test> <events> <test-event type="changing" /> <test-event type="changed" /> </events> </test> Is it possible, through attributes, or sim...

I have a custom type which I want to serialize, this custom type accepts input which might consists of escape chars.

I have a custom type which I want to serialize, this custom type accepts input which might consists of escape chars. M1_Serilizer(MyCustomType customTypeObj) { XmlSerializer serializer = new XmlSerializer(typeof(MyCustomType)); StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); serializer.Serialize(sw, customT...

Best Practice for Serialize/Deserialize from Java to XML

What is the most appropriate way to serialize Java Classes to XML? I tried JAXB, but it has issues with Interfaces and Generics. What sollution is least intrusive but scalable? ...

Using Altova XmlSpy with web services!

Jumping into a project I'm kinda stuck. A project that worked with XML through Altova XmlSpy generated objects and as a intern I got stuck wiht trying to implement it as a Web Service a project that had been started and then abandoned. One problem I notice is that we had been trying to return from the web method one of the objects creat...

How do I serialize an object to xml but not have it be the root element of the xml document

I have the following object: public class MyClass { public int Id { get; set;} public string Name { get; set; } } I'm wanting to serialize this to the following xml string: <MyClass> <Id>1</Id> <Name>My Name</Name> </MyClass> Unfortunately, when I use the XMLSerializer I get a string which looks like: <?xml versi...

How to use DataContractSerializer to create xml with tag names that match my known types

I have the following data contract: [CollectionDataContract(Name="MyStuff")] public class MyStuff : Collection<object> {} [DataContract(Name = "Type1")] [KnownType(typeof(Type1))] public class Type1 { [DataMember(Name = "memberId")] public int Id { get; set; } } [DataContract(Name = "Type2")] [KnownType(typeof(Type2))] public cla...

Why does a carriage-return character disappear when converting a string to SQL Server XML datatype?

Whenever I parse a string to SQL XML datatype I notice that carriage-returns disappear whenever whitespace and XML carriage returns are mixed. If they are not mixed things work fine. Does anyone know why this is happening? See the SQL example code below DECLARE @var XML PRINT 'This is a statement with two XML carriage-return character...

How to prevent lxml prom compacting elements?

Having following Python code: >>> from lxml import etree >>> root = etree.XML("<a><b></b></a>") >>> etree.tostring(root) '<a><b/></a>' How can I force lxml to use "long" version? Like >>> etree.tostring(root) '<a><b></b></a>' ...

How do I match complete XML objects in a string?

I'm attempting to find complete XML objects in a string. They have been placed in the string by an XmlSerializer, but may or may not be complete. I've toyed with the idea of using a regular expression, because it seems like the kind of thing they were built for, except for the fact that I'm trying to parse XML. I'm trying to find comple...

C# XML Serialisation Only Serialise Single Element in List

Given some sample XML such as: <XML> <EMPLOYEES> <EMPLOYEE isBestEmployee="false">John"<"/EMPLOYEE> <EMPLOYEE isBestEmployee="true">Joe"<"/EMPLOYEE> <EMPLOYEE isBestEmployee="false">Bill"<"/EMPLOYEE> </EMPLOYEES> </XML> How do I serialise just the employee with isBestEmployee="true" to a single Employee...

How to serialize this Xml in .NET (array)

I need Xml that looks like this <foo> <bar ... /> <bar ... /> </foo> And currently have the following class structure : [XmlRoot("foo")] public class Foo { [XmlArrayItem("bar")] public List<Bar> myBars; } But this gives me Xml where bar items are wrapped inside a bars element. How should I define my custom XmlAttributes so ...

How to control Time zone formatting in System.Xml.Serialization or during application execution?

I'm developing a C# .Net Application that is executing on a system located in the Central Time Zone. The application gets information from a third party using an API they provide. I have used the WSDL to produce the code that my application access the API with...their reporting API allows you to define a start date and end date for the r...

How can I serialize this .NET Collection item?

Hi folks, I'm trying to xml serialize a POCO view data class into xml. It serializes, but incorrectly generates some xml. eg. (current result .. not the one I'm after) <ReviewListViewData> <reviews> <review>....</review> ... </reviews> </ReviewListViewData> I'm trying to get (notice how I've removed the bad r...

Serialize nested interface

Hello, how can i serialize this class? public class MyClass { IInterface MyProperty { get; set;} } ...

Remove namespace from generated XML in .NET

Possible Duplicate: XmlSerializer: remove unnecessary xsi and xsd namespaces I'm generating some XML using XMLSerializer and a class marked up with attributes. This XML is sent to a REST web service. It generates the following XML: <?xml version="1.0" encoding="utf-8"?> <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-ins...

DataContractSerializer: preserve string member that happens to be raw xml?

I'm a little inexperienced with the DataContract paradigm, and I'm running into a deserialization problem. I have a field that's a string, but it contains xml and it's not being deserialized correctly. I have a feeling that it's because the DCS is treating it as input to the serializer and not as an opaque string object. Is there some w...

Need help with writing from XML to a SQL Server database (detailed)

I'm a bit of a newbie with XML and WebServices and stuff like that. I'm working on a project using GlassFish OpenESB to schedule a process to get some information from a webservice and then store in a database. The criteria is basically that i have to use GlassFish OpenESB or EJB modules where i can expose webservices or something alon...