I have large number of various XML documents I need to ingest into MongoDB using Groovy. Now I have problem that there isn't any generic way to convert any XML into Object based on some simple rules, at least I can't find any. What I would like to do, take any random XML, and create object which will contain timestamps, integers, strings as well maps, basically it would be all decomposed based on the XML structure.
For example, to do it in PHP, is to convert it into JSon, and from JSon into Object. Now I would like to add some converters that for certain elements in XML I would run little routine to e.g. convert timestamps, and I would like to also map certain values as integers, intervals and so on.
I looked on XStream but it requires me to create Object definition for each XML, otherwise it throws "unresolvable" exception.
Is there better way than to do it manually? In Groovy iterating thru XML is not really very fast, I would prefer to use some Java library to do it, even if it's quite of dynamic style operation.
Analogue tool for logfiles is called LogStash. It can have embedded JRuby evaled code in config to convert certain fields of logfiles like timestamps and ingest them into elastic search as object documents.
No comments:
Post a Comment