[jdom-interest] getChildText() by attribute

Frank Sauer Frank.Sauer at trcinc.com
Wed Jan 30 08:15:06 PST 2002

This is a job for XPath. Check out www.jaxen.org


-----Original Message-----
From: Igal Corcos [mailto:scarface at MAGMA.CA]
Sent: Wednesday, January 30, 2002 11:04 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] getChildText() by attribute


Is there a way to get the value associated with an element based on the
value of one of it's attributes?
If not, has anyone considered adding such a method to the Element class...

i.e. getChildTextByAttribute(String name, String attrName, String attrValue)

This method would return the text value for the child element that has an
attribute called 'attrName' and whose value is equal to 'attrValue'... this
would be helpful in situations like the one below:

    <Feature name="HairColor">Brown</Feature>
    <Feature name="EyeColor">Blue</Feature>
    <Feature name="Height">5' 10''</Feature>

We could then simply say:
personElement.getChildTextByAttribute("Feature", "name", "HairColor") to get

Just a thought.
-Igal Corcos

To control your jdom-interest membership:

More information about the jdom-interest mailing list