TinyXml - turn off case sensitivity

Started by
10 comments, last by Genjix 19 years, 1 month ago
^^
Advertisement
XML is case-sensitive.
Quote:Original post by Genjix
^^
What does this mean?
From the little I've used it I see no option to do this. It is probably something you could modify in the source in a few minutes though - you'd need to alter FirstChild() and the Attribute() methods although I'd recommend changing it so using it normally it works as before. ie pass through a bool specifying case-sensitivity which defaults to true.
From what (probably little) I know about TinyXML's internals, the easiest way would be if you hacked up a custom string type that had case-insensitive comparison.
Quote:Original post by d000hg
Quote:Original post by Genjix
^^
What does this mean?
From the little I've used it I see no option to do this. It is probably something you could modify in the source in a few minutes though - you'd need to alter FirstChild() and the Attribute() methods although I'd recommend changing it so using it normally it works as before. ie pass through a bool specifying case-sensitivity which defaults to true.

They are 2 arrows pointing to the above question. The problem is TinyXml uses custom string class, so what Ill probably do is take the passed in string (by changing the parameter name), and convert it to lower case, so from TinyXml's view its all the same. I just would've thought with their extensive ifdefs there would be something for this.
Quote:
XML is case-sensitive.

I perfectly know this, but unfortunately the standards don't meet my requirements. If a user of my program decides (s)he wants to use uppercase, I think thats reasonable. Thanks.
You can tell TinyXML to use stl though - doesn't this include string functionality? But as far as changing the library goes changing the signature from:
TiXmlNode::FirstChild(const char *name)
to
TiXmlNode::FirstChild(const char *name, bool caseSensitive=true)
sounds good to me - that way if you use it elsewhere you don't risk running into odd problems. Or you could just add a new method FirstChildCI(const char *) but that seems less elegant.
Please DO NOT make your XML parser case-insensitive. This would make it accept badly-formed XML documents, as the following XML is not well-formed:

<test></TEST>


Instead, make your application case-insensitive in its treatment of element and attribute names. That way you still only accept well-formed XML.

Mark
Quote:Original post by markr
Please DO NOT make your XML parser case-insensitive. This would make it accept badly-formed XML documents, as the following XML is not well-formed:

<test></TEST>


Instead, make your application case-insensitive in its treatment of element and attribute names. That way you still only accept well-formed XML.

Mark

<test></test><TEST></TEST><Test></Test>

that means 3 checks, for 3 different elements?
No, do not do three checks for three different elements, instead after parsing but before you try to interpret your XML data, convert things to lowercase or use a case-insensitive compare function.

I don't know why you want to make XML case insensitive anyway. Is it too difficult to write the element names in the proper case?

XML is defined as being case sensitive and most applications which read it are. But not in every case, it's entirely up to the application.

Mark
Why not preprocess the xml file, converting all tags to lowercase before passing it to TinyXML?

This topic is closed to new replies.

Advertisement