9

i'm using GetElementsByTagName to extract an element from an xml. GetElementsByTagName is case sensitive - it throws an exception if the node name is 'PARAMS' instead of 'Params'. i dont want that , can i use a different way in XMLDocument so it wont be case sensitive ?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Rodniko
  • 4,926
  • 20
  • 69
  • 93
  • I'm pretty sure the DOM specifies case-sensitivity - although I know some libraries (eg. one of PHPs) don't always behave this way. XML itself is always case-sensitive. Knowing which language you are using would be helpful. More background information would be helpful. What is the problem you are actually looking to solve? See http://www.catb.org/~esr/faqs/smart-questions.html#goal – Rushyo Sep 15 '10 at 09:47
  • thakn you, I'm writing in C#. I'm receiving the XML by a WCF service. when i get the XML i dont want the code to fail just because one of the XML nodes is 'name' instead of 'Name' or even 'NAME', when i analyze it using GetElementsByTagName. – Rodniko Sep 15 '10 at 10:50
  • But why? Since XML is case-sensitive, nobody should ever give you a document with those characteristics. It's a malformed document if they do - and you should probably just handle the exception and tell them off! – Rushyo Sep 15 '10 at 10:54
  • Since XML is case-sensitive, it seems there could be elements with TagName="PARAMS", and other elements with TagName="Params" (even though one or the other may be incorrect for your application. You should be able to do `nodeList1=document.getElementsByTagName("PARAMS")` to get a list of `` nodes, and `nodeList2=document.getElementsByTagName("Params")` to get a list of `` nodes. It's unclear why you would be getting an error for either statement. – Kevin Fegan Mar 28 '21 at 04:11

1 Answers1

11

Since my other answer was deemed 'not an answer', yet the answer is clearly no, let's try again with a more succinct and to the point post:

can i use a different way in XMLDocument so it wont be case sensitive

No.

Now the questioner can improve his answer count and I won't have to question the sanity of moderators here.

Rushyo
  • 7,495
  • 4
  • 35
  • 42