This content has been marked as final. Show 2 replies
I'd imagine Flex (like most XML parsers) would parse the smaller file faster, since most of them simply read tokens from the stream as they arrive, so the less time it takes to arrive, the quicker it can be parsed into a message.
As for the XML format, that's up to you. Typically my rule for attributes is that it should really be data used to identify or sort a tag, such as an ID, a timestamp or maybe a name. However, content typically should go inside the tag, or in a child-tag within it.
So in your case I would probably put your event tag something like:
<Event dDate="1" CustName="test2">test</Event>
Or if you think you will have events later that might need more content parts:
<Event dDate="1" CustName="test2">
Both reduce the size a bit by using attributes but should hopefully remain neat enough to be useful. It's very much a case that XML isn't 100% strict on when to use attributes or child-tags, or rather, there are too many cases where it's unclear. So as I say, attributes are usually useful for identifying, sorting or specifying something important (type*). While actual data that won't be used for any of these goes in child-tags.
* What I mean by 'type' is if you had property called "DataType" that defined the event as being one containing text, or an integer. Then this goes as an attribute since it determines the behaviour when reading the content.
I hope that's useful, and hopefully some others will comment as well as I'm hardly an expert.
As an additional note; if your requirements are ONLY performance, then (if you can) you may wish to consider a non-XML format. While XML is great for readability, and Flex has some great tools for working with raw XML strings, it is very wasteful (as you've seen), refer to the document for Sockets in Flex. However, they are much more complex to implement. As noted in another thread I'm trying to port a currently Java-based Binary XML format over to Flex, but I'm very much in research stages, it's a way off yet. However, it basically takes XML tags and turns them into short-hand forms that are quicker to send, and sends certain data-types as raw bytes. It's good as the difference in size due to attributes verus tags is non-existent. But yeah, gonna be a while till I complete it for Flex, and the Java one is not open-source as I may have to change the specification at any time.
Thanks for the good answer :)