Fix cases where the program would generate incorrect parsing code for elements and attributes with disallowed characters

One example of this is if you have an element <foo-bar>. The generated code
for this would attempt to find and parse <foo_bar> instead.