Select XML Node - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Select XML Node

Demo Code

// All rights reserved.
using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;/*from  w ww  .  ja v a2s .  c  o m*/

public class Main{
        #endregion

        #region Misc
        public static XmlNode SelectNode(XmlNode parentNode, string attributeName, string attributeValue)
        {
            XmlNode node = null;
            if (parentNode.HasChildNodes)
            {
                string nodeName = parentNode.ChildNodes[0].Name;
                string path = nodeName + "[@" + attributeName + "='" + attributeValue + "']";
                node = parentNode.SelectSingleNode(path);
            }
            return node;
        }
}

Related Tutorials