Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:17:50+00:00 2026-05-16T00:17:50+00:00

I try to read an XML file that contains the following element: <ho:CODED-TYPE ho:BASE-DATA-TYPE=A_UINT16

  • 0

I try to read an XML file that contains the following element:

<ho:CODED-TYPE ho:BASE-DATA-TYPE="A_UINT16" CATEGORY="STANDARD-LENGTH-TYPE" ENCODING="UNSIGNED">

My class to describe this node looks like that:

public ref class FIBEXCodedType 
 {
 public:
  [XmlAttribute("ho:BASE-DATA-TYPE")]
  property String^ BaseDataType;

  [XmlAttribute("CATEGORY")]
  property String^ Category;

  [XmlAttribute("ENCODING")]
  property String^ Encoding;

  FIBEXCodedType(void);
 };

I get an InvalidOperationException from XmlSerializer.ctor telling me:

“Ungültiges Namenszeichen in ‘ho:BASE-DATA-TYPE’.” (this could be translated as “invalid character in: ‘ho:BASE-DATA-TYPE'”).

I also tried the following:

[XmlAttribute("BASE-DATA-TYPE", Namespace="http://www.asam.net/xml")]
property String^ BaseDataType;

But this didn’t work either. This time without the error message but the unit test fails telling me, that the property is still set to “null”.

I am completely stuck with this. So any help is appreciated

thanks in advance

EDIT: some more XML

<?xml version="1.0" ?>
<fx:FIBEX xmlns:fx="http://www.asam.net/xml/fbx" xmlns:ho="http://www.asam.net/xml" xmlns:can="http://www.asam.net/xml/fbx/can" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="fibex4can.xsd" VERSION="3.1.0">

<fx:CODING ID="codingSpeed">
    <ho:SHORT-NAME>CodingSpeed</ho:SHORT-NAME>
    <ho:DESC>Coding for speed values within this system.</ho:DESC>
    <ho:CODED-TYPE ho:BASE-DATA-TYPE="A_UINT16" CATEGORY="STANDARD-LENGTH-TYPE" ENCODING="UNSIGNED">
    <ho:BIT-LENGTH>16</ho:BIT-LENGTH>
    </ho:CODED-TYPE>
</fx:CODING>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:17:51+00:00Added an answer on May 16, 2026 at 12:17 am

    rewritten entire answer after edit by OP

    My original understanding of the error was wrong. The error is thrown on the initialization of the serializer, not when you read your XML. You cannot use a colon : 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).

    After doing so, you already noticed that the value ends up null. 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:

    <!-- this works (if namespaces are indeed different -->
    <ho:CODED-TYPE fx:BASE=DATA-TYPE="A_UINT16"...>
    
    <!-- this works, unqualified name takes namespace of parent element -->
    <ho:CODED-TYPE BASE=DATA-TYPE="A_UINT16"...>
    
    <!-- this fails, because XmlSerializer does not expect qualified attributes -->
    <ho:CODED-TYPE ho:BASE=DATA-TYPE="A_UINT16"...>
    

    This seems an odd bug. Here’s somewhat similar report on thisn at MSDN, which helped me to the solution. Just mark the attribute as qualified. The following works with your input XML (note XmlSchemaForm.Qualified):

    [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; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did anyone try to read programmatically an Alibre Design CAD file? I see that
In the following code, I try to read data from a plist: -(void)readPreferences {
I'd like to read in an XML file that is stored on my Tomcat
I have binary data in a file that I can read into a byte
I am developing a webpart that should read an XML file. For this I
When parsing valid XML file private static boolean isXml(FileReader f) { try { saxReader.read(f);
I have an xml file that I am using linq-to-XML to read. Linq-to-XML is
I try to read file /proc/'pid'/status, using c program. The code is as follows,
fopen is failing when I try to read in a very moderately sized file
I'm using the following code to try to read the results of a df

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.