0

How can I retrieve a list of items from a context.xml file?

Here is the context:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/mypath">
    <Environment name="url" value="http://www.google.com"
                 type="java.lang.String" override="false"/>
    <Environment name="user" value="user"
                 type="java.lang.String" override="false"/>
    <Environment name="password" value="password"
                 type="java.lang.String" override="false"/>
</Context>

I can access the individual items using this code:

InitialContext initialContext = new InitialContext();
javax.naming.Context context = (javax.naming.Context) initialContext.lookup("java:comp/env");
String baj_url = (String)context.lookup("url");

But how can I get a collection of all three items without specifiying the items by name? Is there a way to loop through them all?

navig8tr
  • 1,724
  • 8
  • 31
  • 69
  • Possible duplicate of [Which is the best library for XML parsing in java](https://stackoverflow.com/questions/5059224/which-is-the-best-library-for-xml-parsing-in-java) – Progman Jun 13 '19 at 18:45
  • @Progman That is not a duplicate for this question. – Mark Rotteveel Jun 15 '19 at 09:10

0 Answers0