2

The server I use at work (out of my control) always uses XML in the responses/requests. So I have to receive XML, parse it (with FAST currently), make all the objects by hand and then send back an XML response after some application activity. It's not the best way to do things.

Haxe has pretty good Json support but not really for XML. You have to traverse the XML elements and it's not all that efficient. I'm trying to make my life easier because the client's service always uses XML.

I'd love to be able to take in XML and output an object easily like in Java.

The trouble is, I have no clue how I would even go about this.

Is it worth going down this road? I suppose I could take a look at the Java one and try to re-implement it in Haxe?

Would embedding an external one be a better option? Any suggestions?

Has anyone had experience with this library? https://github.com/proletariatgames/hxinflate

Or would just extending the already-implemented parts of the library be the most practical thing to do? http://haxe.org/manual/std-serialization.html

I'm using Fast API and it works but it's always nice to have something even more convenient.

user1261710
  • 2,539
  • 5
  • 41
  • 72
  • Have you tried the [Fast API](http://old.haxe.org/doc/advanced/xml_fast)? Or are you saying that's insufficient too? – MSGhero May 09 '15 at 19:46
  • I'm using Fast API right now and I mean it works fine but it doesn't match up to anything like in Java. I'm trying to gauge how hard it would be to implement something like that and if it's worth it. – user1261710 May 09 '15 at 21:18

1 Answers1

2

What you can do is use the neko program found here https://github.com/jasononeil/haxelib-xml-to-json to change your xml server response to json then use the haxe.Json class to change that into a Dynamic typed object. The program in the link loads in .xml files and exports .json so you'll have to save what you get from the server to file first then load it again. You can probably cut out the middle man if you just write a class to handle the conversion using the link above as a guide.

  • Thanks very much. It's a pretty cool idea. I'll try it out. Would you happen to have an idea of how difficult it would be to implement a java-like serilization? – user1261710 May 10 '15 at 18:59
  • 1
    There's the [TJSON](https://github.com/martamius/TJSON) lib which can serialize classes to json. Then it's the reverse to get it from json to xml. There's also haxe's serializer if you don't require json/xml output. – MSGhero May 11 '15 at 02:22