XML traversing using XmlDocument

前端 未结 2 676
不知归路
不知归路 2021-01-18 07:46

I have the following code, which I use to traverse the XML:

private void btn_readXML_Click(object sender, EventArgs e)
{
        var doc = new XmlDocument();         


        
2条回答
  •  迷失自我
    2021-01-18 07:57

    Try this:

    private void btn_readXML_Click(object sender, EventArgs e)
    {
            var doc = new XmlDocument();
            doc.Load("e:\\contacts.xml");
    
            var nodes = xdoc.SelectNodes("//yournodename");
            // ex. 
            // var nodes = xdoc.SelectNodes("//Company");
            TraverseNodes(nodes);   
    }
    

提交回复
热议问题