Fixing bad XML in Lua -


I have a Leah program that is consuming data from an external device, the device is returning defective XML that looks :

  & lt; Element attribute 1 = "value 1" attribute 2 = "value 2" attribute 3 = "m" value 3 "" attribute 4 = "value 4" />  

Especially some field users are editable and may include items that should not be saved, but are not. Hopefully I can get the code to fix these messages, but by then 'I try to do the right thing' I have an alternative solution. Always in a single order the messages start coming in a certain format and always exist (as far as I can tell) so I can use a very restrictive pattern match like:

 < Code> string .mail (str, 'attribute1 =' (. *) "Attribute2 =" (. *) "Attribute 3 =" (. *) "Attribute 4 =" (. *) ")  

but it looks really icky and if they decide to change the format, then surely there will be a break.

Optional solution Any suggestions for not? I'm not worried mainly as I much "other XML entities.

Unfortunately, if such a XML is incorrect, then you can not do anything that exactly matters Will work in

What I will do, first of all, try to parse it as a normal XML. If he fails, he will return to his regex method. In this way, when the creators of this XML are fixed, then your code will start automatically, that's right.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -