XElement.GetNamespaceOfPrefix Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets the namespace associated with a particular prefix for this XElement.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- prefix
- Type: System.String
A string that contains the namespace prefix to look up.
Return Value
Type: System.Xml.Linq.XNamespaceAn XNamespace for the namespace associated with the prefix for this XElement.
The following example creates an XML tree that has a namespace with an associated prefix. It then uses this method to retrieve the XNamespace for the prefix.
'add the following line to the the Imports section: 'Imports <xmlns:aw="http://www.adventure-works.com"> Dim output As New StringBuilder Dim xmlTree As XElement = <aw:Root/> Dim awNamespace As XNamespace = GetXmlNamespace(aw) output.Append(String.Format("Namespace: {0}", awNamespace)) output.Append(Environment.NewLine) OutputTextBlock.Text = output.ToString()
Show: