java - What is the better way to save a (xml) file from a url? -


currently, here i'm wanting do:

  • save xml file computer url
  • parse , grab information want (which isn't of it)
  • compare parsed information yesterdays version of xml

so can multiple different things, want memory efficient way possible. don't want take forever parse , compare files either.

option 1:

  • directly parse xml url , save array
  • iterate through array , create new xml file parsed information want doing this create new xml file.
  • compare 2 xml files
  • write new xml file based on differences between xml

option 2:

  • download xml file using of these suggested methods (will keep xml structure?)
  • parse xml array
  • compare 2 xml files
  • write new xml

these 2 options i've been looking into, know there more. not sure if more effective, haven't had direct access internet computer few days can't test them against each other. when able test awhile back, noticed takes awhile parse information directly website.

the xml structure looks 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 best option parsing, comparing, , writing xml file is.

when able test online, took awhile parse through xml without saving it. went considerably faster when xml file located on computer. downloading file preserve xml format? worth keeping information don't need xml in case need later on? or have parse , write out (which seem take longer) keep format?

when comparing things xml or json or other serialization format, more concerned data binary content. mean

<reps>8</reps> 

is equivalent

<reps       >8</reps> 

my suggestion download xml file, use library jaxb parse , convert (keyword: unmarshal) contents of file java object (or list/set). same previous version of file. compare java objects. sets, can calculate difference between 2 , create new file containing differences (keyword: marshal).


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -