Link to home
Start Free TrialLog in
Avatar of richardsimnett
richardsimnett

asked on

Java XML Tree Reading continued

Hello,
I have a program which loads an XML document as its config file. I use xpath to retrieve items from it, however, I need to be able to get the names of sub node values (not sure if I am explaining this right). Here is a chunk of the xml config:

<mtas>
      <mta1>
        <bind_ip>192.168.1.115</bind_ip>
        <mta_name>mx1.goforit.com</mta_name>
        <mta_port>25</mta_port>
        <mta_distributor_connections>5</mta_distributor_connections>
        <mta_distribute_to>192.168.1.115</mta_distribute_to>
        </mta1>

      <mta2>
<bind_ip>192.168.1.115</bind_ip>
<mta_name>mx2.goforit.com</mta_name>
<mta_port>25</mta_port>
<mta_distributor_connections>5</mta_distributor_connections>
<mta_distribute_to>192.168.1.115</mta_distribute_to>
</mta2>
-
      <mta3>
<bind_ip>192.168.1.115</bind_ip>
<mta_name>mx3.goforit.com</mta_name>
<mta_port>25</mta_port>
<mta_distributor_connections>5</mta_distributor_connections>
<mta_distribute_to>192.168.1.115</mta_distribute_to>
</mta3>
-
      <mta4>
<bind_ip>192.168.1.115</bind_ip>
<mta_name>mx4.goforit.com</mta_name>
<mta_port>25</mta_port>
<mta_distributor_connections>5</mta_distributor_connections>
<mta_distribute_to>192.168.1.115</mta_distribute_to>
</mta4>
-
      <mta5>
<bind_ip>192.168.1.115</bind_ip>
<mta_name>mx5.goforit.com</mta_name>
<mta_port>25</mta_port>
<mta_distributor_connections>5</mta_distributor_connections>
<mta_distribute_to>192.168.1.115</mta_distribute_to>
</mta5>
</mtas>

as you can see under the <mtas> tag I have 5 other structures defined. I need to be able to retrieve a list of these structures by name and have them returned to me as a comma delimited string... ie I would call a function called getValueList("root/mtas") and it would return to me mta1,mta2,mta3,mta4,mta5.

Worth 500 points.

Thanks,
Rick
   
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of richardsimnett
richardsimnett

ASKER

objects,
Ok from looking at the API I get how to work with a nodelist... however, which function do I use on the individual Node to get the name mta1, etc...?

Thanks,
Rick
Objects,
Thanks for your help... got this working very nicely.

-Rick