CSharp examples for System.Xml:XML Element
Casting XML element to string
using System.Xml.Linq; using System;//w w w. ja va 2 s .c om public class Main{ /// <summary> /// Casting element to string /// </summary> /// <param name="element"></param> /// <param name="key"></param> /// <returns></returns> public static String CastAttributeToString(this XElement element, String key) { if (element.Attribute(key) == null) { return ""; } return element.Attribute(key).Value; } }