Skip to content

Issue with return value of XmlNamespaceManager.LookupPrefix #7474

@andersjonsson

Description

@andersjonsson

Issue description

The docs says that the return value of XmlNamespaceManager.LookupPrefix returns The matching prefix. If there is no mapped prefix, the method returns String.Empty. If a null value is supplied, then null is returned.
My tests indicate that this method returns null if there is no mapped prefix.

Example:

XmlNamespaceManager mgr = new XmlNamespaceManager(new NameTable());

var prefix = mgr.LookupPrefix("http://www.microsoft.com");

if (prefix == null)
	Console.WriteLine("Prefix is null");
else
	Console.WriteLine("Prefix is not null");

This code outputs "Prefix is null". According to the docs the returned prefix should have been String.Empty.

Target framework

  • .NET Core 5.0
  • .NET Framework 4.8
dotnet --info output or About VS info
<replace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityarea-System.Xmldoc-bugProblem with the content; needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions