I wrote a C # small program today, using file operations, regular expressions and XML

xiaoxiao2021-03-06  84

It took a night, looked at MSDN, with writing code and debugging, finally wrote, and read Yao Ming's NBA game. Haha, I am so happy ~ The first time I write C # procedures ^ _ ^ Very simple project, big cow don't joke me ~ Take more valuable comments. To the point! Background: In the company's project, some useful information is written to log, and it will debug programmers when there is a problem. Due to the non-stop test of the test department, this log is increasing, when there is a problem, it may have no patience and means to see LOG. If bug is reproducible, then reuse logs can solve the problem; but some logs are difficult to reproduce, then this huge log may contain important information. Therefore, I want to write a program to extract information concerned. Log's organization: Log recorded XML Packet interacting between servers and clients, and has recording time, priority, and more. Therefore, this structure is blank -> information -> xml -> blank cycle. Where the XML node has a Type property to mark what XML Packet debugging, we want to extract the basic TYPE XML Packet. Practice: The idea is basically: delete the blank line, delete the information line, organizes XML to XML, query the XML of a specific Type property, I started to use VC to implement (company development language is VC , very much contact with C # ). Operate the file via cfile, operate XML by cmarkup. But these two operations are very uncomfortable. I spent hard, writing a lot of code, some features still don't realize. Depressed, I remembered that I have read some articles in the Bo Guest Hall recently, some introduced that C # uses regular expressions and XML, so she wants to implement it with C #. Code: After some effort, it is made, haha, the core code is listed below, where red part is a key code, or the core of the algorithm