CSharp examples for System.Xml:XML Document
Get Node XML from XmlDocument
// Copyright (c) 2006-2017 All Rights reserved * using System.Xml.XPath; using System.Xml; using System.IO;/*from w w w . jav a 2 s . c o m*/ using System.Globalization; using System; public class Main{ public static string GetNodeXML(XmlDocument document, string XPath, string defaultValue) { return GetNodeXML(document, XPath, defaultValue, false); } #endregion #region GetNodeXML public static string GetNodeXML(XmlDocument document, string XPath, string defaultValue, bool useOuter) { try { XmlNode node = null; node = document.SelectSingleNode(XPath); if (node == null) return defaultValue; else if (useOuter) return node.OuterXml; else return node.InnerXml; } catch (Exception ex) { throw; } } }