Huayi software controlled XML to Excel

Source: Internet
Author: User

The company encrypts the system with the Hua product. Recently, the company wants to re-comb the company's information security management situation, the carding and optimization of China-Path encryption system is the top priority.

Today, the company leaders asked it to export all the software in the system, the suffix of the controlled situation, and then it Chi Chi to the Chinese software in the XML sent to the leadership, the results of leadership does not know how to open the XML file. Wait until the leader uses IE to open XML, see is full screen of the heavenly book. The end of it I can only say: Old miserable ...

The leader sees XML such as:

The format of this XML is still very clear: Moduleinfo defines the software version, process identification, classification, control type and other information. The file suffix to be controlled is defined under the Include node, and the exclude node defines an uncontrolled file suffix.

So, the idea of solving this problem is simple: Read this XML file by code, escape to the format that the leader can understand, save into Excel.

//define result set
Sclist = new list<securecontrol> ();
//Read XML file
string xmlfile = Path.Combine ( Application.startuppath, "XML", "config:");
XElement Xele = xelement.load (xmlfile);
//Read Moduleinfo node collection
ilist<xelement> a = Xele. Descendants ("Moduleinfo"). ToList (); Moduleinfo

foreach (XElement x in a)
{
Try
{
Read the node properties, get the software version and other information.
Securecontrol sc = new Securecontrol ();
Sc. Ischaracteristic = X.attribute ("Ischaracteristic"). Value;
Sc. iscontroled = X.attribute ("iscontroled"). Value;
Sc. Process = X.attribute ("process"). Value;
Sc. Softtype = X.attribute ("Softtype"). Value;
Sc. Softversion = X.attribute ("Softversion"). Value;
Sc. Include = "";
Sc. Exclude = "";
Traversal read include
Ilist<xelement> include = X.descendants ("include"). Descendants ("FileType"). ToList ();
foreach (XElement ic in include)
{
Sc. Include + = (IC. Value + "");
}
Traversal read exclude
Ilist<xelement> exclude = x.descendants ("Exclude"). Descendants ("FileType"). ToList ();
foreach (XElement ex in Exclude)
{
Sc. Exclude + = (ex. Value + "");
}
Inserts a result set for displaying
Sclist.add (SC);
}
Catch
{ }
}

Gridcontrol1.datasource = sclist;

Effect Show:

Read interface

Saved in Excel:

Huayi software controlled XML to Excel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.