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</bi nd_ip>
<mta_name>mx1.goforit.com< /mta_name>
<mta_port>25</mta_port>
<mta_distributor_connectio ns>5</mta_ distributo r_connecti ons>
<mta_distribute_to>192.168 .1.115</mt a_distribu te_to>
</mta1>
<mta2>
<bind_ip>192.168.1.115</bi nd_ip>
<mta_name>mx2.goforit.com< /mta_name>
<mta_port>25</mta_port>
<mta_distributor_connectio ns>5</mta_ distributo r_connecti ons>
<mta_distribute_to>192.168 .1.115</mt a_distribu te_to>
</mta2>
-
<mta3>
<bind_ip>192.168.1.115</bi nd_ip>
<mta_name>mx3.goforit.com< /mta_name>
<mta_port>25</mta_port>
<mta_distributor_connectio ns>5</mta_ distributo r_connecti ons>
<mta_distribute_to>192.168 .1.115</mt a_distribu te_to>
</mta3>
-
<mta4>
<bind_ip>192.168.1.115</bi nd_ip>
<mta_name>mx4.goforit.com< /mta_name>
<mta_port>25</mta_port>
<mta_distributor_connectio ns>5</mta_ distributo r_connecti ons>
<mta_distribute_to>192.168 .1.115</mt a_distribu te_to>
</mta4>
-
<mta5>
<bind_ip>192.168.1.115</bi nd_ip>
<mta_name>mx5.goforit.com< /mta_name>
<mta_port>25</mta_port>
<mta_distributor_connectio ns>5</mta_ distributo r_connecti ons>
<mta_distribute_to>192.168 .1.115</mt a_distribu te_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
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</bi
<mta_name>mx1.goforit.com<
<mta_port>25</mta_port>
<mta_distributor_connectio
<mta_distribute_to>192.168
</mta1>
<mta2>
<bind_ip>192.168.1.115</bi
<mta_name>mx2.goforit.com<
<mta_port>25</mta_port>
<mta_distributor_connectio
<mta_distribute_to>192.168
</mta2>
-
<mta3>
<bind_ip>192.168.1.115</bi
<mta_name>mx3.goforit.com<
<mta_port>25</mta_port>
<mta_distributor_connectio
<mta_distribute_to>192.168
</mta3>
-
<mta4>
<bind_ip>192.168.1.115</bi
<mta_name>mx4.goforit.com<
<mta_port>25</mta_port>
<mta_distributor_connectio
<mta_distribute_to>192.168
</mta4>
-
<mta5>
<bind_ip>192.168.1.115</bi
<mta_name>mx5.goforit.com<
<mta_port>25</mta_port>
<mta_distributor_connectio
<mta_distribute_to>192.168
</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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Objects,
Thanks for your help... got this working very nicely.
-Rick
Thanks for your help... got this working very nicely.
-Rick
ASKER
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