複数のXMLファイルから特定のXMLタグの数を数える小さなXMLツールを作成しました。
このためのコードは次のとおりです。
public void SearchMultipleTags()
        {
            if (txtSearchTag.Text != "")
            {
                try
                {
                    //string str = null;
                    //XmlNodeList nodelist;
                    string folderPath = textBox2.Text;
                    DirectoryInfo di = new DirectoryInfo(folderPath);
                    FileInfo[] rgFiles = di.GetFiles("*.xml");
                    foreach (FileInfo fi in rgFiles)
                    {
                        int i = 0;
                        XmlDocument xmldoc = new XmlDocument();
                        xmldoc.Load(fi.FullName);
                        //rtbox2.Text = fi.FullName.ToString();
                        foreach (XmlNode node in xmldoc.GetElementsByTagName(txtSearchTag.Text))
                        {
                            i = i + 1;
                            //
                        }
                        if (i > 0)
                        {
                            rtbox2.Text += DateTime.Now + "\n" + fi.FullName + " \nInstance: " + i.ToString() + "\n\n";
                        }
                        else 
                        {
                            //MessageBox.Show("No Markup Found.");
                        }
                        //rtbox2.Text += fi.FullName + "instances: " + str.ToString();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Path or Empty File name field.");
                }
            }
            else
            {
                MessageBox.Show("Dont leave field blanks.");
            }
        }
このコードは、ユーザーが必要とする複数のXMLファイルのタグ数を返します。
同じように、XMLファイルに存在する特定のテキストとその数を検索したいと思います。
XMLクラスを使用してコードを提案できますか。
よろしくお願いいたします。MayurAlaspure