Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>rewritten entire answer after edit by OP</em></p> <p>My original understanding of the error was wrong. The error is thrown on the initialization of the serializer, <em>not</em> when you read your XML. You cannot use a colon <code>:</code> in a name. If you specify a namespace, do not specify the prefix. Actually, you hardly ever specify the prefix (which is just a placeholder for the namespace).</p> <p>After doing so, you already noticed that the value ends up <code>null</code>. The reason is that the serializer defaults to unqualified attributes. If you have qualified attributes, it assumes the attribute namespace is different than the element's namespace. This will work:</p> <pre><code>&lt;!-- this works (if namespaces are indeed different --&gt; &lt;ho:CODED-TYPE fx:BASE=DATA-TYPE="A_UINT16"...&gt; &lt;!-- this works, unqualified name takes namespace of parent element --&gt; &lt;ho:CODED-TYPE BASE=DATA-TYPE="A_UINT16"...&gt; &lt;!-- this fails, because XmlSerializer does not expect qualified attributes --&gt; &lt;ho:CODED-TYPE ho:BASE=DATA-TYPE="A_UINT16"...&gt; </code></pre> <p>This seems an odd bug. Here's <a href="http://support.microsoft.com/kb/816222" rel="nofollow noreferrer">somewhat similar report on this</a>n at MSDN, which helped me to the solution. Just mark the attribute as qualified. The following works with your input XML (note <code>XmlSchemaForm.Qualified</code>):</p> <pre><code>[XmlRoot(ElementName = "FIBEX", Namespace = "http://www.asam.net/xml/fbx")] public class FIBEX { [XmlElement("CODING", Namespace = "http://www.asam.net/xml/fbx")] public FIBEXCoding Coding { get; set; } } public class FIBEXCoding { [XmlElement("SHORT-NAME", Namespace = "http://www.asam.net/xml")] public string ShortName { get; set; } [XmlElement("DESC", Namespace = "http://www.asam.net/xml")] public string ShortDescription { get; set; } [XmlElement("CODED-TYPE", Namespace = "http://www.asam.net/xml")] public FIBEXCodedType Codedtype { get; set; } } public class FIBEXCodedType { [XmlAttribute("BASE-DATA-TYPE", Namespace = "http://www.asam.net/xml", Form=XmlSchemaForm.Qualified)] public string BaseDataType { get; set; } [XmlAttribute("CATEGORY")] public string Category { get; set; } [XmlAttribute("ENCODING")] public string Encoding { get; set; } [XmlElement("BIT-LENGTH", Namespace = "http://www.asam.net/xml")] public int BitLength { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload