Get Xml Lang Attribute - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Xml Lang Attribute

Demo Code

// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml;
using System.Runtime;
using System.Globalization;
using System.Collections.Generic;

public class Main{
        public static string GetXmlLangAttribute(XmlReader reader)
        {//ww  w  .  ja  va 2s .  co m
            string xmlLang = null;
            if (reader.MoveToAttribute("lang", XmlNs))
            {
                xmlLang = reader.Value;
                reader.MoveToElement();
            }

            if (xmlLang == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.XmlLangAttributeMissing));

            return xmlLang;
        }
}

Related Tutorials