Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace EditorLocalizedStrings
- {
- public partial class Form1 : Form
- {
- TableManager TM = new TableManager();
- public Form1()
- {
- InitializeComponent();
- TM.BindData(this.dataGridView1);
- }
- public class TableManager
- {
- private string _filePath;
- XmlElement documentElement;
- public bool isEnd()
- {
- return true;
- }
- public string FilePath
- {
- get { return _filePath; }
- set { _filePath = value; }
- }
- private XmlElement BuildingXmlStructure()
- {
- XmlDocument document = new XmlDocument();
- try
- {
- document.Load(FilePath);
- }
- catch
- {
- }
- documentElement = document.DocumentElement;
- return documentElement;
- }
- public void BindData(DataGridView dgv)
- {
- XmlNode node = BuildingXmlStructure();
- if(node != null)
- {
- foreach (XmlNode firstXMLNode in node.ChildNodes)
- {
- if (firstXMLNode.Name == "token")
- {
- XmlNode attr = firstXMLNode.Attributes.GetNamedItem("name");
- var i = dgv.Rows.Add();
- dgv.Rows[i].Cells[0].Value = attr.Value;
- dgv.Rows[i].Cells[1].Value = firstXMLNode.InnerText;
- }
- }
- }
- }
- }
- private void Button2_Click(object sender, EventArgs e)
- {
- openFileDialog1.InitialDirectory = "c:\\";
- openFileDialog1.Filter = "xml files (*.xml)|*.xml";
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- TM.FilePath = openFileDialog1.FileName;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement