Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

doanelinde

macrumors member
Original poster
Jul 24, 2009
35
0
I'm parsing an xml file into a coredata database and am just wondering how I would go about checking for updated versions of the xml file using the version number? Is there an easy way to do this?


The database would only be updated every couple of months or so, and there would be massive overhead parsing the whole file every time the app runs..
 
Do you have control of the content of the XML file? If so, maybe add an attribute or node with the version number and then just parse for that. NSXMLParser doesn't require the whole file to be parsed; it does it piecemeal.
 
Yes I have access to the file. Is there not some generic way to access the version number though, I thought there was?
 
Yes I have access to the file. Is there not some generic way to access the version number though, I thought there was?
XML files can have a version number in their header but that is in reference to the version of XML the file is using and not the version of the content. I'd suggest adding a <contentVersion> node to the file and parsing for that.
 
Ok, say I'm using the books example for example, instead of the first book object I just have content and then when I'm parsing I have an if statement checking whether elementname=book or content?
 
Yep, this is what the xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Book id="1">
<title>Circumference</title>
<author>Nicholas Nicastro</author>
<summary>Eratosthenes and the Ancient Quest to Measure the Globe.</summary>
</Book>
<Book id="2">
<title>Copernicus Secret</title>
<author>Jack Repcheck</author>
<summary>How the scientific revolution began</summary>
</Book>
<Book id="3">
<title>Angels and Demons</title>
<author>Dan Brown</author>
<summary>Robert Langdon is summoned to a Swiss research facility to analyze a cryptic symbol seared into the chest of a murdered physicist.</summary>
</Book>
<Book id="4">
<title>Keep the Aspidistra Flying</title>
<author>George Orwell</author>
<summary>A poignant and ultimately hopeful look at class and society, Keep the Aspidistra Flying pays tribute to the stubborn virtues of ordinary people who keep the aspidistra flying.</summary>
</Book>
</Books>
 
Okay, I would just add a <contentVersion> node ahead of the <Books> node and then you can also parse for elementName == "contentVersion".
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.