Read XML from last viewed node

  • Thread starter Thread starter G-Oker
  • Start date Start date
G

G-Oker

Guest
Hello,

I am writing a program that looks when an XML file has been changed (date /time) and then read through the nodes.

<?xml version="1.0"?>
<nodeList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Collector.xsd"><topNode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="001.xsd">
<Office>
<version>3EH30519ECAA </version>
</Office>
<Checksum>157722544</Checksum>
<TicketType>Call</TicketType>
<Type>A</Type>
<ID>275</ID>
<TType>P</TType>
<Date>2019-04-23</Date>
<Time>11:15:00</Time>
<Duration>00:00:27</Duration>
</CallAccounting>
</nodeList>




using (myStream)


{
xmldoc.Load(FldPath + "\\filename.xml");
XmlNodeList topNode = xmldoc.GetElementsByTagName("topNode"); // Locate nodes in dropped calls file
int topNode Found = topNode.Count; // if the above has been found, count how many times

if (topNode Found > 0)
{
tbOutput.Focus();

for (int i = 0; i < topNode.Count; i++)
{
string chksum = topNode["Checksum"].InnerText;
string Ticktype = topNode["TicketType"].InnerText;
string CUType = topNode["Type"].InnerText;

etc...



..and this works great.

HOWEVER, when a new node(s) are added, this procedure goes thought the whole document again.

What I would like it to do it carry on for the last read node.... but I do not know how to do this (and I have not tried anything because of this, as I cannot figure out the pseudo-code).

the checksum value will always be different, so I thought that I might store the last value in a variable, then perform the relevant action if chksum != lastChkSunValue; , but this would do every line EXCEPT when lastChkSunVaue = chksum.


Can someone please advise/show me/point me in the direction of, hoI i can read an XML file ONLY from the last point (IE: only the newly added nodes)?


Thanks in advance

Continue reading...
 
Back
Top