dotnet / dotnet/dotnet-api-docs

Issue with return value of XmlNamespaceManager.LookupPrefix

Open
#7,474 3 comments 0 reactions 0 assignees View on GitHub
area-System.Xml doc-bug Pri3
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

**Issue description**

The [docs](https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmlnamespacemanager.lookupprefix?view=net-5.0#returns) 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**

- [x] .NET Core 5.0
- [x] .NET Framework 4.8

dotnet --info output or About VS info

```console

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.