I have a simple XML file with the following format:
<data>
<group id="group1">
<upper>
<item id="A">
<stage age="1 Week">
<property1>1</property1>
<property2>AC</property2>
</stage>
</item>
</upper>
<lower>
<item id="A">
<stage age="1 Week">
<property1>2</property1>
<property2>AN</property2>
</stage>
</item>
</lower>
</group>
</data>
Each 'item' contains about 30 'stages', each 'upper'/'lower' contains around 15 'items', and the document contains 2 'groups', so it's a pretty sizeable bit of data. I've been told that in order to speed up searching through this data (incidentally, if it makes any difference, I'm using Actionscript to search through it), I should be using attributes for 'property1' and 'property2', not child elements.
So, I have two questions:
1) Will it really speed things up a lot? At the moment, I'm having to compare about 50 user input values to each value in the XML, and looping through it all can take up to 40 seconds.
2) Is there a program available that can easily change the code above into something like this:
<data>
<group id="group1">
<upper>
<item id="A">
<stage age="1 Week" property1 = "1" property2 = "AC" />
</item>
</upper>
<lower>
<item id="A">
<stage age="1 Week" property1 = "2" property2 = "AN" />
</item>
</lower>
</group>
</data>
It seems like this should be a fairly simple thing to automate, so I'm hoping there's something out there. I've done some googling and found out about XSLT, but I literally just learned that it exists this morning so I'm not in a place where I know how to use it (yet).
Any help would be greatly appreciated.
Posts
This would also be very simple to write in something like .NET - are you looking for an already existing app or curious about how to write it yourself?
As for your speed question - XML performance varies significantly between programming technologies, and even then between different implementations. What are you using for searching right now?
As for what I'm using, the XML is being imported into a flash file, where I'm using E4X in Actionscript 3 to process the thing.
Never heard of such a thing: that's what XSLT is for (except it's a bitch to learn)
<person name="John" age="26" gender="Male" />