all groups > dotnet xml > august 2004 >
You're in the

dotnet xml

group:

XmlSerializer does not deserialize elements /w specified namespace?



Re: XmlSerializer does not deserialize elements /w specified namespace? Kirby Turner
8/31/2004 7:39:22 AM
dotnet xml: You can add the XmlElementAttribute( Namespace="") to your class
Surfaces if you want to use a different namespace than the one used by
LandXML.

-KIRBY


On Tue, 31 Aug 2004 11:54:23 +0200, Daniel Lidström
[quoted text, click to view]
XmlSerializer does not deserialize elements /w specified namespace? Lidström
8/31/2004 11:54:23 AM
Hi,

the class looks like this:

[XmlRootAttribute(Namespace="http://www.landxml.org/schema/LandXML-1.0",IsNullable=false)]
public __gc class LandXML {
public:
...
};

public __gc class Surfaces
{
public:
...
};

and the element like this:
<Surfaces name="Triangles" xmlns="">
....
</Surfaces>

If I remove the xmlns="" then the element is deserialized properly. But not
when it is there. Why is this? The top element is in another namespace:

<?xml version="1.0" encoding="Windows-1252"?>
<LandXML xsi:schemaLocation="http://www.landxml.org/schema/LandXML-1.0
http://www.landxml.org/schema/LandXML-1.0/LandXML-1.0.xsd" version="1.0"
date="2004-06-03" time="16:05:24"
xmlns="http://www.landxml.org/schema/LandXML-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

So what does this mean? Is the Surface element in another namespace, and
should not be deserialized? How can I `force' the Surfaces element to be
deserialized, regardless of what namespace it is in?
Thanks!

--
Re: XmlSerializer does not deserialize elements /w specified namespace? Lidström
9/1/2004 9:47:33 AM
[quoted text, click to view]

Surfaces.h(130) : error C3303:
'System::Xml::Serialization::XmlElementAttribute': attribute can only be
used on 'properties, fields, parameters, return values'

Perhaps you mean XmlRootAttribute, or XmlTypeAttribute?

--
AddThis Social Bookmark Button