XML Serialization from MSDN:
Serializes and deserializes objects
into and from XML documents. The
XmlSerializer enables you to control
how objects are encoded into XML.
Reflection from MSDN
Reflection provides objects (of type
Type) that encapsulate assemblies,
modules and types. You can use
reflection to dynamicall...
Following on from a previous question, I am having trouble combining the Lazy<T> generic that was suggested with my XML Serialization.
Here is the functionality I am using for Lazy<T>:
public struct Lazy<T> where T : class, new()
{
private T _Value;
public bool HasValue
{
get
{
return (_Value !=...
Is there a way to force XML elements generated from XML serialisation to be ordered in the same way as defined in the object class?
i.e.
class SerializableClass
{
[XmlElement("Element.1")]
public List<string> Element1
{
get { return _Element1; }
set { _Element1 = value; }
}
private List<string> _...
I am having problems serializing a cdata section using c#
I need to serialize XmlCDataSection object property as the innertext of the element.
The result I am looking for is this:
<Test value2="Another Test">
<![CDATA[<p>hello world</p>]]>
</Test>
To produce this, I am using this object:
public class Test
{
[System.Xml.Serial...
The file format I'm working with (OFX) is XML-like and contains a bunch of plain-text stuff before the XML-like bit begins. It doesn't like having between the plain-text and XML parts though, so I'm wondering if there's a way to get XmlSerialiser to ignore that. I know I could go through the file and wipe out that line but it would be s...
I a class containing multiple properties of type string. One of the values contains a character of hex value 96. If I serialize the class to xml, the xml serializer does not encode that character, and if I view the xml in various tools such as IE or SQLServer with OpenXML, it complains that the character is invalid in an xml document. ...
Consider a simple case
public class Test {
public String myString;
}
Is there any way I can tell XmlSerializer to base64 encode myString when serializing it ?
...
I used xsd.exe to generate a C# class for reading/writing GPX files. How do I get the resultant XML file to include the xsi:schemaLocation attribute
eg.
I want the following but xsi:schemaLocation is always missing
<?xml version="1.0"?>
<gpx
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/20...
I have added web service reference in visual studio. I am able to see xml return value from web method. How should I read data from returned XML of service?
...
I've written a DataSet to a XML file using .WriteXML(FileName), and the DataSetName property of the dataset is the top-level tag in the file. However, when I try to read the file into a different DataSet using .ReadXML(FileName), the DataSetName isn't changed to the value of the top-level tag. Am I doing something wrong, or is ReadXML no...
I have a collection of objects and for each object I have its type FullName and either its value (as string) or a subtree of inner objects details (again type FullName and value or a subtree).
For each root object I need to create a piece of XML that will be xml de-serializable.
The problem with XmlSerializer is that i.e. following obje...
I am using this method to serialize my object:
public static string XmlSerialize(object o)
{
var stringWriter = new StringWriter();
var xmlSerializer = new XmlSerializer(o.GetType());
xmlSerializer.Serialize(stringWriter, o);
string xml = stringWriter.ToString();
stringWriter.Close();
return xml;
}
It makes XML...
I'm trying to deserialize XML with two namespaces, like this
<records xmlns="http://www.foo.com/xml/records/1.1">
<record xmlns="http://www.foo.com/xml/record/1.1">
and sometimes an older version
<records xmlns="http://www.foo.com/xml/records/1.1">
<record xmlns="http://www.foo.com/xml/record/1.0">
My Records.cs...
I've got a DLL that contains some XSD-generated classes. Unfortunately, XSD.exe makes those classes public, which results in "Missing XML comment for publicly visible type or member XYZ" warnings. Plus, I'd rather not expose those classes from my DLL. Is there a way, short of manually editing the generated .cs, to make those classes i...
When serializing a custom generic collection to Xml how do I add an attribute to the generated collection element.
Currently I have:
<RootObject>
<Id>1</Id>
<Items>
<MyCollectionItem/>
<MyCollectionItem/>
</Items>
</RootObject>
What I need is:
<RootObject>
<Id>1</Id>
<Items Name="My collection name">
<MyCollec...
I have a web service that's serializing a class (class is from the web service) into an MSMQ, then a windows service is checking the queue and deserializing. The windows service has a web reference to get the class.
If I deserialize inside the web service, everything comes out fine. However, when I deserialize from the windows service...
I'm trying to get my httphandler to print out an XML file with the format:
<ScheduledShows>
<ScheduledShowElement>...</ScheduledShowElement>
<ScheduledShowElement>...</ScheduledShowElement>
<ScheduledShowElement>...</ScheduledShowElement>
</ScheduledShows>
But for some reason, the attribute XmlRoot("ScheduledShowElement") ...
I currently have a WCF service to consume a remote REST service with the following:
[ServiceContract]
[XmlSerializerFormat]
public interface IMyApi
{
[OperationContract]
[WebGet(
ResponseFormat = WebMessage.Xml,
UriTemplate = "RemoteServicePage.jsp")]
MyNewClass Send();
}
The nice part about this is the XmlSerializerFormat attr...
We're connecting to a web service and the fault message we're getting back isn't deserializing (at all), and no version of class that I can make will deserialize correctly. We have no control over the server side of things. The server does not allow for discovery, so adding ?WSDL to the end of the URL of the endpoint results in an error,...
If I create a class in C#, how can I serialize/deserialize it to a file? Is this somethat that can be done using built in functionality or is it custom code?
...