c # – iterate XmlDocument with xpath

How do we script an XmlDocument using an xpath?

I'm trying to return a list of nodes by xpath:

    public static List Filter(string xpath, string input, string ns, string nsUrl)
        var bytes = Encoding.UTF8.GetBytes(input);
        var stream = new MemoryStream(bytes);
        var doc = new XmlDocument();
        XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
        namespaceManager.AddNamespace(ns, nsUrl);
        var links = new List();
        var nodes = doc.SelectNodes(xpath, namespaceManager);
        using (var reader = new XmlTextReader(stream))
            reader.Namespaces = false;
        foreach (XmlNode node in nodes)
            if (IsNullOrWhiteSpace(node.InnerText))

        return links;

However, the account is still 0!

I'm using this xpath:


The header of the file looks like this:

I am sure to use the correct xpath because I tested it against my payload:

enter the description of the image here

I call the function this way:

            var links = Filter(xpath, xml, "ns0", "http://NameSpace.ExternalSchemas.Patient");

How do we script an XmlDocument using an xpath?