Currently, here is what I'm wanting to do:
- Save the xml file to my computer from a url
- Parse it and grab the information that I want (which isn't all of it)
- Compare the parsed information to yesterdays version of the xml
So I can do multiple different things, but I want to do it the most memory efficient way as possible. I also don't want it to take forever to parse and compare the files either.
Option 1:
- Directly parse the xml from the url and save it into an array
- Iterate through the array and create a new xml file with only the parsed information I want doing something like this to create the new xml file.
- Compare the two xml files
- Write new xml file based on the differences between the xml
Option 2:
- Download the xml file using any of these suggested methods (will this keep the xml structure?)
- Parse the xml into an array
- Compare the two xml files
- Write a new xml
These are the two options I've been looking into, but I know there are more. Not sure if they are more effective, but I haven't had direct access to the internet with my computer for a few days so I can't really test them against each other. When I was able to test it awhile back, I noticed it takes awhile to parse the information directly from the website.
The xml structure looks something like this:
<Data>
<User>
<ID>1</ID>
<Name>Bob</Name>
<Age>18</Age>
<IsOnline>false</IsOnline>
<Sport>Basketball</Sport>
<GymPresence>
<LastSeen>April 12 2013</LastSeen>
<Picture>www.gym.com/picId=10000</Picture>
<Weights>
<Machine>Bench</Machine>
<Weight>175</Weight>
<Reps>8</Reps>
</Weights>
</GymPresence>
</User>
<User>
<ID>2</ID>
<Name>Joe</Name>
<Age>23</Age>
<IsOnline>false</IsOnline>
<Sport>Baseball</Sport>
<GymPresence>
<LastSeen>April 10 2013</LastSeen>
<Picture>www.gym.com/picId=10001</Picture>
<Weights>
<Machine>Bench</Machine>
<Weight>205</Weight>
<Reps>8</Reps>
</Weights>
</GymPresence>
</User>
...
... # 3 through 124
...
<User>
<ID>125</ID>
<Name>Amy</Name>
<Age>17</Age>
<IsOnline>false</IsOnline>
<Sport>Volleyball</Sport>
<GymPresence>
<LastSeen>April 13 2013</LastSeen>
<Picture>www.gym.com/picId=10124</Picture>
<Weights>
<Machine>Bench</Machine>
<Weight>105</Weight>
<Reps>5</Reps>
</Weights>
</GymPresence>
</User>
</Data>
Overall, I'm wondering what the best option is for parsing, comparing, and writing an xml file is.
When I was able to test it online, it took awhile to parse through the xml without saving it. It went considerably faster when the xml file was located on my computer. But would downloading the file preserve the xml format? Is it worth keeping the information I don't need from the xml in case I need it later on? Or would I have to parse it and write it out (which would seem like it would take longer) to keep the format?