XmlTextReader.XmlLang Property gets the current xml:lang scope.
Imports System
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim xmlFrag as string = "<book xml:lang='en-US'> " & _
" <title xml:lang='en-GB'>C#</title>" & _
" <title>XML</title>" & _
"</book>"
Dim nt as NameTable = new NameTable()
Dim nsmgr as XmlNamespaceManager = new XmlNamespaceManager(nt)
Dim context as XmlParserContext = new XmlParserContext(nothing, nsmgr, nothing, XmlSpace.None)
Dim reader as XmlTextReader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context)
reader.WhitespaceHandling = WhitespaceHandling.None
while (reader.Read())
select case reader.NodeType
case XmlNodeType.Element:
Console.WriteLine("{0}: <{1}>", reader.XmlLang, reader.Name)
case XmlNodeType.Text:
Console.WriteLine("{0}: {1}", reader.XmlLang, reader.Value)
case XmlNodeType.EndElement:
Console.WriteLine("{0}: </{1}>", reader.XmlLang, reader.Name)
end select
end while
reader.Close()
end sub
end class
Related examples in the same category