drmohundro / SWXMLHash

Simple XML parsing in Swift
MIT License
1.4k stars 203 forks source link

Accept digits at the start of attribute names #266

Closed nudefireninja closed 1 year ago

nudefireninja commented 1 year ago

Is your feature request related to a problem? Please describe. Yes, some of my XML files are not fully parsed. Parsing stops when an attribute name begins with a digit.

Describe the solution you'd like A less strict parsing mode would be nice.

Describe alternatives you've considered Using a regex to fix attribute names before parsing.

Additional context XML attributes should not start with digits according to some (unofficial) sources I found, but in practice not all tools adhere to that.

Example:

<physics_shape_rotation 00="1" 01="0" 02="0" 10="0" 11="1" 12="0" 20="0" 21="0" 22="1"/>

drmohundro commented 1 year ago

SWXMLHash wraps the Swift XMLParser, so it is at the mercy of how strict XMLParser is. I think having a character prefix is all that would be needed for the attributes. Is this XML generated by your application or something else? And does it follow some other standard?

nudefireninja commented 1 year ago

Oh, totally missed that!

It just says <?xml version="1.0" encoding="UTF-8"?> at the top. It's from a game. But I managed to fix it with some simple search and replace.

Thanks for replying! Great library! 👍

drmohundro commented 1 year ago

Happy to help and thanks!