I have an XML file that is constantly being appended to. I need to read in the data from the XML repeatedly, but on each pass I do not want to retrieve data that I have processed in the previous run.
Since I know how long the file is at the time of processing, I figure I could use the length of the file (minus the ending /Contacts tag) to determine where I last left off. Knowing this, what is the best way to retrieve all of the Contact tags starting from a particular byte position within the file?
<?xml version="1.0"?>
<Contacts>
<Contact>
<Name>Todd</Name>
<Email>todd@blah.com</Email>
</Contact>
<Contact>
<Name>Sarah</Name>
<Email>sarah@blah.com</Email>
</Contact>
</Contacts>
This block of code grabs all of the contacts. I would like to limit it so it only picks up data after the first contact (at byte 116.)
var xdoc = XDocument.Load(PATH_TO_FILE);
var contact = xdoc.Descendants("Contact").Select(x => (string)x).ToArray();
I found a way to save/retrieve by index position. This will work just as well.