Re: HOWTO Overcome missing namespace declaration in root node

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Christoph Schittko [MVP] (christophdotnetINVALID_at_austin.rr.com)
Date: 04/22/04


Date: Wed, 21 Apr 2004 23:44:50 -0500

David,

Can you post:

* The serialization class
* the tag of the root element, including all namespace definitions
* the line of code where you instantiate the XmlSerializer

-- 
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"David B. Bitton" <david@codenoevil.com> wrote in message
news:%23Je9uj6JEHA.2244@tk2msftngp13.phx.gbl...
> I am having a problem deserializing XML when the root node is missing a
> namespace declaration.  My Type has an XmlTypeAttribute with a namespace
> defined.  If I attempt to deserialize the XML, I get the dreaded
>
> <elementname xmlns=''> was not expected
>
> exception.  If I comment out the XmlTypeAttribute, it works just fine.
Just
> so you know, when I instantiate an instance of an XmlSerializer, I pass a
> default namespace to the ctor.  Unfortunately that doesn't seem to work.
>
> So, how can I get the XmlSerializer to accept XML that is missing
namespace
> declarations?
>
> -- 
> --
>
> David B. Bitton
> david@codenoevil.com
> www.codenoevil.com
>
> Code Made Fresh DailyT
>
>


Relevant Pages

  • newbie: writing to xml and namespaces
    ... I'm having some issues when programmatically editing an XML file. ... XmlTextWriter and add the default namespace declaration when writing the ... appears other than in the root element. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Openxml() Edge Table - root element problem
    ... parameter in sp_xml_preparedocument (instead of using one of the other root element attributes)? ... http://www.ups.com/XMLSchema/EBR/Billing/v1 is the namespace in the default namespace declaration of the root element of your posted XML sample. ... Or should I be searching for the applicable string in the original .xml doc for each new doc? ... or is the openxml() parse strictly internal? ...
    (microsoft.public.sqlserver.xml)
  • Re: XML from SQL
    ... I have read ALOT on XML over the last few weeks. ... element and the namespace but I was having problems including the ... To fix the problem you could consider to create the root element on the ... since MS SQL Server 2005 you can use ...
    (microsoft.public.sqlserver.xml)
  • Re: Cannot find root element in XML file
    ... Well if you simply want to access the root element then ... will do whatever the name of the element is and whatever namespace that ... documents nodes fails. ... parsed correctly by .NET XML framework, ...
    (microsoft.public.dotnet.xml)
  • Re: XmlSerializer, C# , Excel, XML and SpreadsheetML
    ... To get the arrays to emit the correct xml tags you can add the ... To force the namespace prefix on the attribute add the ... XmlSerializer xs = new XmlSerializer); ... public Cell[] Cells; ...
    (microsoft.public.dotnet.framework)