2 Replies Latest reply on May 11, 2010 10:12 AM by Mike schwery

    Getting <env-entry> values from web.xml with dom

    Mike schwery Novice

      I'm trying to get the  <env-entry> values from the web.xml with dom in jython and I'm stuck.

      The attached file is what works foar. Any help is appreciated

        • 1. Re: Getting <env-entry> values from web.xml with dom
          Jean-Frederic Clere Master

          Guessing.... in Servlet? - You need a JNDI lookup for the entry-name you created -

          • 2. Re: Getting <env-entry> values from web.xml with dom
            Mike schwery Novice

            I'm trying to read the  env-entry values in the web.xml with a jython script.

            So far I've got the following working .

             

            from org.w3c.dom import *

            from javax.xml.parsers import *

             

            def jndiSearch(file):

             

            factory = DocumentBuilderFactory.newInstances()

            builder = factory.newDocumentBuilder()

            doc = builder.parse(file)

            serverResults = doc.getElementsByTagName('env-entry')

            for iw in range(serverResults.getLength()):

               print "found"

               serverResults1 = serverResults.item(iw).getChildNodes()

               for iy in range(serverResults1.getLength()):

                  elem = serverResults1.item(iy)

                  test = elem.getNodeValue()

                  print test

             

             

            It is reading the file segment

             

            <env-entry>

            <env-entry-name>a</env-entry-name>

            <env-entry-type>string</env-entry-type>

            <env-entry-value>1</env-entry-value>

            </env-entry>

             

            My output is

            found

             

             

            None

             

             

             

            It shoulde be

            found

            a

            string

            1

             

            I'm stuck as to how to get the text for the children of <env-entry>.