code: public static List<PersistenceUnitMetadata> findPersistenceUnits(final URL url, final String[] persistenceUnits,
              PersistenceUnitTransactionType defaultTransactionType) throws InvalidConfigurationException
      {
          Document doc;
          try
          {
              doc = getDocument(url);
          }
          catch (InvalidConfigurationException e)
          {
              throw e;
          }
          doc.getXmlVersion();
          Element top = doc.getDocumentElement();
  
          String versionName = top.getAttribute("version");
  
          NodeList children = top.getChildNodes();
          ArrayList<PersistenceUnitMetadata> units = new ArrayList<PersistenceUnitMetadata>();
  
          // parse for persistenceUnitRootInfoURL.
          for (int i = 0; i < children.getLength(); i++)
          {
              if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
              {
                  Element element = (Element) children.item(i);
                  String tag = element.getTagName();
                  // look for "persistence-unit" element
                  if (tag.equals("persistence-unit"))
                  {
                      PersistenceUnitMetadata metadata = parsePersistenceUnit(url, persistenceUnits, element, versionName);
                      if (metadata != null)
                      {
                          units.add(metadata);
                      }
                  }
              }
          }
          return units;
      }
docs: Find persistence units.
  
  @param url
  the url
  @param defaultTransactionType
  the default transaction type
  @return the list
  @throws Exception
  the exception