Deserialize XML: Name cannot begin with the '0' character, hexadecimal value 0x30. Line 3, position 3

Please Find Attached Screenshot and XML File

Sample.xml (8.7 KB)

Main.xaml (11.9 KB)

Variable Type XDocument
I used System.Web.API Package…for XML

How can I solve this error ?


You are supposed to change the tag name since the one you wrote violates XML standards. Just to remember the interesting portion of it here:

XML Naming Rules

XML elements MUST follow these naming rules:

  • Names can contain letters, numbers, and other characters
  • Names cannot start with a number or punctuation character
  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • Names cannot contain spaces

Any name can be used, no words are reserved.

as a suggestion to solve your problem mantaining the standard:

  1. Use an attribute, ie < Number value="0"/>
  2. Add a prefix to the tag ie <_0/>

Cheers @kishan.savaliya


As @Palaniyappan mentioned <0> is invalid element name.
In addition <Unit Cost> is also invalid.

So we can parse it after string manipulation as the following, for example.


strXML = System.Text.RegularExpressions.Regex.Replace(strXML,"(?<=\</?)(\d+)(?=\>)","_$1").Replace("Unit Cost>","Unit_Cost>")

Main.xaml (6.2 KB)


1 Like

Thank You @Palaniyappan for the Valuable Information about XML Naming Rule which I forgot.

1 Like

Thank You @Yoichi for the Valuable Solution

Glad it got clarified @kishan.savaliya

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.