CSharp examples for System.Xml:XML Node
Get Xml Root Node
using System.Xml; using System.Text; using System.Linq; using System.Collections.Generic; using System;// w ww . j av a 2 s . c o m public class Main{ public static XmlNode GetXmlRootNode(String fileName, String nodeName) { XmlDocument doc = new XmlDocument(); XmlTextReader textReader = new XmlTextReader(fileName); XmlNode currNode = doc.ReadNode(textReader); while (currNode != null) { if (currNode.NodeType == XmlNodeType.Element) { if (currNode.Name.Equals(nodeName, StringComparison.OrdinalIgnoreCase)) return currNode; } currNode = doc.ReadNode(textReader); } return null; } }