code: @Override
      public List<NugetPackageReference> parse(InputStream stream) throws MSBuildProjectParseException {
          try {
              final DocumentBuilder db = XmlUtils.buildSecureDocumentBuilder();
              final Document d = db.parse(stream);
  
              final XPath xpath = XPathFactory.newInstance().newXPath();
              final List<NugetPackageReference> packages = new ArrayList<>();
  
              final NodeList nodeList = (NodeList) xpath.evaluate("//PackageReference", d, XPathConstants.NODESET);
  
              if (nodeList == null) {
                  throw new MSBuildProjectParseException("Unable to parse MSBuild project file");
              }
  
              for (int i = 0; i < nodeList.getLength(); i++) {
                  final Node node = nodeList.item(i);
                  final NamedNodeMap attrs = node.getAttributes();
  
                  final Node include = attrs.getNamedItem("Include");
                  final Node version = attrs.getNamedItem("Version");
  
                  if (include != null && version != null) {
                      final NugetPackageReference npr = new NugetPackageReference();
  
                      npr.setId(include.getNodeValue());
                      npr.setVersion(version.getNodeValue());
  
                      packages.add(npr);
                  }
              }
  
              return packages;
          } catch (ParserConfigurationException | SAXException | IOException | XPathExpressionException | MSBuildProjectParseException e) {
              throw new MSBuildProjectParseException("Unable to parse MSBuild project file", e);
          }
      }
docs: Parses the given stream for MSBuild PackageReference elements.
  
  @param stream the input stream to parse
  @return a collection of discovered NuGet package references
  @throws MSBuildProjectParseException if an exception occurs