GetElementsByTagName which is not case sensitive?
Asked Answered
C

2

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 ?

Cyanate answered 15/9, 2010 at 9:37 Comment(4)
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 catb.org/~esr/faqs/smart-questions.html#goalNightcap
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.Cyanate
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!Nightcap
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 <PARAMS ...> nodes, and nodeList2=document.getElementsByTagName("Params") to get a list of <Params ...> nodes. It's unclear why you would be getting an error for either statement.Hapten
N
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.

Nightcap answered 12/8, 2012 at 23:5 Comment(0)
W
0

instead of

getElementsByTagName()

Use

selectNodes("//PARAMS | //params")
Whew answered 21/8, 2024 at 2:55 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.