Jump to content
  • Advertisement
Sign in to follow this  
Genjix

TinyXml - turn off case sensitivity

This topic is 4915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
XML is case-sensitive.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!