Recently, someone often saw someone inquiry how to use XML in C Builer, starting the author also thinking is inexplicable, first XML technology seems to be linked to the network, or SOAP / Web Service, second C Builer provides TXMLDocument components, it should be very user-friendly. These days were studying Tomcat, found that its profile was written in XML files, and it seems that this represents the software's advanced type :), so I also decided to use C Builer to operate XML files to increase their own software. At this time, I deeply feel the confusion of those inquiors, and the TXmldocument component is really difficult. If there is an experience of the ASP XML construction website, I really have to be difficult to fall by this problem :), nonsense, talk to the topic . Processing XML files must of course require XML Parser, and XML Parse includes SAX, DOM, and SAX is relatively simple. The DOM model is more difficult, and C Builer is using the DOM model to process XML files, so mainly discussed here DOM model processing method. The TXMLDocument component uses the MS XML DOM model to process XML, MSXmldom is COM based, using this COM in tools such as VB, and it is not easy in C Builer, I think it is large because We are very easy to understand and use, and many methods are very easy to understand. Many methods are meaningless, and even help do not need to be checked, and the author has to check when using TXMLDocument, many methods can not be accurate Know what it means, and even traps. Below I told everyone how to use TXMLDocument to process XML. This example is that, the author needs a minor program for a timed reminder schedule, assuming that other functions are completed, how is the problem now? Save our schedule, here in order to use XML, it is of course stored in XML file format. For a schedule, it is definitely necessary to add a deleted function, and the substantially above operation already contains all of the processing XML. Let's design XML file (TIP.XML): XML Version = "1.0" encoding = "GB2312"?> // Note The encoding format here is GB2312, otherwise there is garbled
The first is to open XML, the current code snippet shows this process: xmldoc-> loadFromfile (WideString (AppPath) "Tip.xml"))); // Xmldoc is the name of TXmldocument xmlDoc-> Active = true; FillList (); // Add XML content to listView then how to read XML content (FillList): LSTMAIN-> items-> beginupdate (); lstimain-> items-> clear (); _di_ixmlnode node = xmldoc > DocumentElement; // DocumentElement property is used to get root node _di_ixmlnodelist nodes = node-> childnodes; // Get child node list for (int N = 0; n