0

I'm trying to pull the version value (2.100.2) where href="someclient.jar" using JAVA. Any suggesstions? I've gotten up to parsing the xml file into a Document.

<?xml version="1.0" encoding="utf-8"?>
    <jnlp>
       <resources>
        <jar href="someclient.jar" version="2.100.2" />
        <jar href="cisco-upgrade.jar" version="1.5" />
        <jar href="collections.jar" version="1.1" />
        <jar href="commons-codec.jar" version="1.4" />
        <jar href="commons-email.jar" version="1.1" />
       </resources>
    </jnlp>

Java:

File fileXML = new File(path);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fileXML);
jdoyle0116
  • 83
  • 2
  • 12
  • 1
    Maybe this will help: http://stackoverflow.com/questions/2811001/how-to-read-xml-using-xpath-in-java – Mark W May 12 '14 at 18:29

1 Answers1

3

Use XPath

String expression = "/jnlp/resources/jar[@href='someclient.jar']/@version";
Arjit
  • 3,290
  • 1
  • 17
  • 18