Created
February 15, 2019 08:40
-
-
Save marchermans/3894f9fe363c0b010984eb2aea47d7e3 to your computer and use it in GitHub Desktop.
Parser for maven-metadata.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<String> parse(URL link) throws IOException, ParserConfigurationException, SAXException | |
{ | |
final List<String> versions = Lists.newArrayList(); | |
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory | |
.newInstance(); | |
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); | |
Document document = docBuilder.parse(link.openStream()); | |
NodeList versionNodes = document.getElementsByTagName("version"); | |
for (int i = 0; i < versionNodes.getLength(); i++) | |
{ | |
Node versionNode = versionNodes.item(i); | |
versions.add(versionNode.getTextContent()); | |
} | |
return versions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment