I am trying to De-serialize XML below to C# classes:
<StaffingOrder xmlns="NameSpaceName">
<ReportingRequirements>
<ns0:ManagerName>__MANAGER_NAME</ns0:ManagerName>
<ns0:SupervisorName>__SUPERVISOR_NAME</ns0:SupervisorName>
</ReportingRequirements>
<Comments>Comment</Comments>
</StaffingOrder>
But while deserializing I am getting following Error:
Error: There was an error processing 'Test.xml'.
- 'ns0' is an undeclared prefix
How can i deserialize ns0 tags.
The XML document is not namespace-well-formed because the prefix ns0 is not bound to any namespace. This is why it cannot be parsed.
It can be bound to a namespace of your choice with an xmlns:ns0 attribute in any tag around its use, like so:
<StaffingOrder
xmlns="NameSpaceName"
xmlns:ns0="http://www.example.com/some/namespace">
<ReportingRequirements>
<ns0:ManagerName>__MANAGER_NAME</ns0:ManagerName>
<ns0:SupervisorName>__SUPERVISOR_NAME</ns0:SupervisorName>
</ReportingRequirements>
<Comments>Comment</Comments>
</StaffingOrder>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.