using System.Xml; // Load the XML document XmlDocument doc = new XmlDocument(); doc.LoadXml("In this example, the LookupPrefix method is used to resolve the "http://example.com/foo" namespace URI to the prefix "foo." The namespace URI is obtained from the "xmlns:foo" attribute on the root element of the XML document. The IXmlNamespaceResolver interface is part of the System.Xml namespace in the .NET Framework."); // Resolve the prefix for the "http://example.com/foo" namespace string prefix = doc.DocumentElement.Attributes["xmlns:foo"].LookupPrefix("http://example.com/foo"); // Output the prefix Console.WriteLine(prefix); // Output: "foo"