R
Russell
I have a class with a single public member. I use the XmlAttribute
attribute to serialize it as an attribute rather than an element.
I want to create methods to serialize and deserialize instances as XML
fragments rather than as whole documents.
When I create an XmlSerializer for the class and serialize it, I get
<?xml version="1.0" encoding="utf-16"?> <POINT
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" wkt="POINT(50.0 100.999)"
/>
when all I really want is an XML fragment without namespace details,
i.e.
<POINT wkt="POINT(50.0 100.999)" />
I'd similarly like to be able to use the XmlSerializer to deserialize
such a fragment.
I could do all this with direct string manipulation or by implementing
IXmlSerializable and my own ReadXML, WriteXML methods if I need to but
I'd like to know if there is a way to do this with the standard XML
serializers.
attribute to serialize it as an attribute rather than an element.
I want to create methods to serialize and deserialize instances as XML
fragments rather than as whole documents.
When I create an XmlSerializer for the class and serialize it, I get
<?xml version="1.0" encoding="utf-16"?> <POINT
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" wkt="POINT(50.0 100.999)"
/>
when all I really want is an XML fragment without namespace details,
i.e.
<POINT wkt="POINT(50.0 100.999)" />
I'd similarly like to be able to use the XmlSerializer to deserialize
such a fragment.
I could do all this with direct string manipulation or by implementing
IXmlSerializable and my own ReadXML, WriteXML methods if I need to but
I'd like to know if there is a way to do this with the standard XML
serializers.