How do you read in an environment variable in an XML file? . . .

Discussion in 'Java' started by Albretch, Nov 7, 2004.

  1. Albretch

    Albretch Guest

    that was set up for and/or by this user in the OS.

    Say, you set WEB_DIR as an environment variable pointing to certain
    folder or root directory

    Could you go like this

    <?xml version='1.0' encoding='utf-8'?>
    <XMLExample Att1="69" Att2=$WEB_DIR"rest_of_it">

    .. . .

    </XMLExample>

    for attributes or values?

    And when a program parses the XML doc it should pick the current env.
    var. value.

    I think of using it for tomcat's configuration files which are more
    XMLish than true XML ones.

    There are ways to pass in parameters to the JVM when you run a java
    prog., but I don't know of a way to read in an external environment
    variable from the OS into an updated conf doc and use this value

    How do you do something like that?
     
    Albretch, Nov 7, 2004
    #1
    1. Advertising

  2. Albretch

    Oscar kind Guest

    Albretch <> wrote:
    > that was set up for and/or by this user in the OS.
    >
    > Say, you set WEB_DIR as an environment variable pointing to certain
    > folder or root directory
    >
    > Could you go like this
    >
    > <?xml version='1.0' encoding='utf-8'?>
    > <XMLExample Att1="69" Att2=$WEB_DIR"rest_of_it">
    >
    > . . .
    >
    > </XMLExample>
    >
    > for attributes or values?

    [...]
    > How do you do something like that?


    Yourself. AFAIK, XML parsers don't expand environemtn variables.

    To get the value of an environment variable, see:
    - System#getProperty(String)
    - Integer#getInteger(String)
    - Long#getLong(String)
    - And similar methods in these classes.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Nov 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 195.229.241.2
    Replies:
    5
    Views:
    4,070
    Tor Iver Wilhelmsen
    Aug 4, 2003
  2. Albretch
    Replies:
    3
    Views:
    5,370
    Albretch
    Nov 8, 2004
  3. B N
    Replies:
    4
    Views:
    883
  4. Replies:
    5
    Views:
    670
  5. bthumber
    Replies:
    0
    Views:
    376
    bthumber
    Jul 6, 2010
Loading...

Share This Page