Last active
December 26, 2015 17:09
-
-
Save jclosure/7184666 to your computer and use it in GitHub Desktop.
Converts between Pascal and Camel cases for xml node names. Really just operates on the first letter of the node name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //C# | |
| string jStrObj = | |
| "<?xml version='1.0' encoding='UTF-8'?><DataObject><id>ea9b96a6-1f8a-4563-9a15-b1ec0ea1bc34</id><name>blah</name><processed>false</processed></DataObject>"; | |
| //to .net style property names | |
| string camelPattern = @"(\<(?:[a-z])|\</(?:[a-z]))"; | |
| jStrObj = Regex.Replace(jStrObj, camelPattern, m => m.Value.ToUpper()); | |
| //to java style property names | |
| /*string pascalPattern = @"(\<(?:[A-Z])|\</(?:[A-Z]))"; | |
| jStrObj = Regex.Replace(jStrObj, pascalPattern, m => m.Value.ToLower());*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment