Get First XML Element - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get First XML Element

Demo Code


using System.Xml.Serialization;
using System.IO;/*from w ww .j a  v a2  s . com*/
using System.Xml;
using System.Text.RegularExpressions;
using System;

public class Main{
        public static XmlElement GetFirstElement(XmlDocument doc, string name)
      {
         XmlNodeList list = doc.GetElementsByTagName(name);
         if (list == null)
         {
            return null;
         }
         return (XmlElement) list.Item(0);
      }
}

Related Tutorials