c# - XmlSerializer adds namespaces to all elements on serializing -


i have serialize function serializes entity (customer object). xmlserializer created using

          new xmlserializer(entity.gettype()) 

i have 2 test cases call function. first test gets a list of customers , sends 1 of active customer serialized works well. xml output created has namespace in root element (i.e. customer element/tag)

example:

<customer xmlns:xsd="http://www.w3.org/2001/xmlschema"  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" domain="xxx"  sparse="false" xmlns="http://schema.xxx.com/finance/v3">    <id>1099</id>... 

second test calls customer queryservice , uses linqextender query results query service , returns active customer. when second test calls serialize method causes xml output have namespace added elements instead of having root element.

example:

<customer xmlns:xsd="http://www.w3.org/2001/xmlschema"  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" domain="xxx"  sparse="false">     <id xmlns="http://schema.xxx.com/finance/v3">1099</id>... 

i compared 2 objects used both first , second test , identical.

i want serializer act consistently in case creating xml output namespaces in root element.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -