I can't believe I can't find this information easily accessible, so:
1) Which characters cannot be incorporated in an XML attribute without entity-encoding them?
Obviously, you need to encode quotes. What about < and >? What else?
2) Where exactly is the official list?
...
Can I make XmlSerializer ignore the namespace (xmlns attribute) on deserialization so that it doesn't matter if the attribute is added or not or even if the attribute is bogus? I know that the source will always be trusted so I don't care about the xmlns attribute.
...
using (var file_stream = File.Create("users.xml"))
{
var serializer = new XmlSerializer(typeof(PasswordManager));
serializer.Serialize(file_stream, this);
file_stream.Close();
}
Using the above code works perfectly. However, when I shorten it to:
var serializer = new...
Hi
I've been reading lately about serialization. I've read that when I use XmlSerialization I cannot serialize object graphs. What is an object graph and why I cannot serialize it simply?
Kind Regards
PK
...
$serializer = new XML_Serializer($options); $serializer->serialize($some_array);
$output = $serializer->getSerializedData();
I want to surround an arbitrary element generating XML with an above cord in CDATA, but I can't do it.
Will not there be any good method?
XML_SERIALIZER_OPTION_CDATA_SECTIONS = true
When I used it with this opti...
Assume I have a C# class like this:
[XmlRoot("floors")]
public class FloorCollection
{
[XmlElement("floor")]
public Floor[] Floors { get; set; }
}
And I want to serialize it and send to a REST API using WCF. But before sending I need adding an attribute to the floors node in this way: <floors type="array">...</floors>
Any id...
In need to serialize an object and it's possible that the assembly version changed while deserialization. Additionally it can happen, that the object changes a bit.
The XmlSerializer does not store type information and if the object changes a bit, it just does not fail, but the XmlSerializer can not serialize private or internal propert...
I have an ASP.NET 2.0 web application running on a shared server of a well known web hosting provider. Occasionally I seem to be getting errors like this:
Could not find file 'C:\WINDOWS\TEMP\lxnmfrsz.dll'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for m...
I am new to the C# XmlSerializer so I might be missing something basic here.
The problem I am running into is that I have one class that has a List<T> of another class. When I serialize the main class the XML looks beautiful and all the data is intact. When I deserialize the XML, the data in the List<T> disappears and I am left with a...
Here is the code:
[XmlRoot("Foo")]
class Foo
{
[XmlElement("name")]
string name;
}
[XmlRoot("FooContainer")]
class FooContainer
{
[XmlElement("container")]
List<List<Foo>> lst { get; set; }
}
XmlSerializer s = new XmlSerializer(typeof(FooContainer)); -->Can't pass thr...
Say I have a simple class like so
[Serializeable]
public class MyClass
{
public MyClass()
{
this.MyCollection = new List<int>();
}
public List<int> MyCollection { get; private set;}
}
If I try to deserialize this using XmlSerializer I get an error saying that MyCollection is readonly and cannot be assigned to....
I've inherited a project where the application's data model is an XML document. The developers before me had created an object model based on this xml's schema, and then coded against the object model.
After several years of maintenance, this application has gradually started to show its age. The team leader has said that the key reason...
Hi,
I'm implementing the ReadXml() method of IXmlSerializable and I figure using XPath is probably the nicest way to do this.
However, ReadXml() needs to handle the reader position properly.
So given that my WriteXml() produces something like this:
<ObjectName>
<SubNode>2</SubNode>
<SubNode>2</SubNode>
</ObjectName>
Is there a ...
In my task would be very nice to write a kind of objects serialization (for XML output). I've already done it, but have no idea, how to avoid recursive links.
The trouble is that some objects must have public(!) properties with links to their parents (it's really nessecary). And when I try to serialize a parent object which agregates so...
I have a class in .NET that implements IXmlSerializable. I want to serialize its properties, but they may be complex types. These complex types would be compatible with XML serialization, but they don't implement IXmlSerializable themselves. From my ReadXml and WriteXml methods, how do I invoke the default read/write logic on the XmlR...
There's a related question What is the preferred Java XML binding framework?
In the answer currently ranked 2nd there, the poster drew a distinction between XML Serialization, and Java/XML data binding. As best I can tell, XML data binding means "creating an in-memory object graph from an XML document". And XML Serialization means "cr...
I am writing an app in C# to serialize and array of double or float to a single XML element that is a space-delimited list of the values in the array.
double[] d = new double[4] { 1.0, 2.0, 3.0, 4.0 };
to the XML element:
<ArrayOfDouble type="double">1.0 2.0 3.0 4.0</ArrayOfDouble>
I am trying to use the XmlSerializer to perform th...
I've run into some problems when trying to serialize my object to XML. The problem appears when trying to serialize a "Profiles" property which is a List of Profile items. Profile is my own type.
The Profile type should ideally be abstract, but it isn't, since XML serialization demands a parameterless ctor. The Profiles property contains...
If you have a null value in a field in a dataset and export it to xml it does "remove" the field tag .. anyway to avoid this..
...
I have a WPF .NET 3.5 SP1 application that is in use on at least hundreds if not thousands of machines at this point. The application stores a tree structure in XML that is loaded at startup. As soon as I try to load the xml via serialization, boom. It only happens on one end user machine. He has admin rights, plenty of disk space, m...