Reading XML with lua
![](https://secure.gravatar.com/avatar/880e9a15b17a0bf7159f4e31030a9be2.jpg?s=120&d=mm&r=g)
Hi, I’ m finally at a point where I can read an XML file look at it and write it back. Right now I have two problems: 1. There are many empty entries in the table. This makes processing the file a little tedious since I have to filter the real entries. 2. Some entries contain leading and trailing whitespace and linkebreaks. These are the result of formatting the XML file. Shouldn't strip_cm_and_dt take care of them? Or do I use that incorrectly? I have included my lua file and an example xml. You can run it with mtxrun —script p.lua Greetings Axel
![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 5/3/2019 5:24 PM, Axel Kielhorn wrote:
Hi,
I’ m finally at a point where I can read an XML file look at it and write it back.
Right now I have two problems:
1. There are many empty entries in the table. This makes processing the file a little tedious since I have to filter the real entries.
2. Some entries contain leading and trailing whitespace and linkebreaks. These are the result of formatting the XML file. Shouldn't strip_cm_and_dt take care of them?
no, as comments and doctype definitions are not the same as spaces
Or do I use that incorrectly?
the stored xml is largely roundtrip
I have included my lua file and an example xml. You can run it with mtxrun —script p.lua
Greetings Axel
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Axel Kielhorn
-
Hans Hagen