Incoming XML case sensitivity issue

Viewed 156

I have a webapi (.NET core 3.1) method which is getting XML and deserializing to object. But some of the tag openings and closings are not same. For example if opens with <Address> then it closed with </address>. So the XML is not well-formed. I know XML is case-sensitive, but is there any option that we can ignore that case-sensitivity?

The XML is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<Orders>
    <User>UserName</User>
    <Address>address line</address>
</Orders>
1 Answers

No

XML component names, including element names, are case sensitive. There is no provision within the standard to change that, nor should you attempt do so on an ad hoc basis because you'd be undermining the XML standard and all benefits of having a standard.

But what should I do?

  1. Fix the problem at the source that's generating the bad "XML" (preferably), or
  2. Fix the bad XML itself. See How to parse invalid (bad / not well-formed) XML?
Related