[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

Frank


-----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


Hello,

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:

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

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

Just a thought.
Thanks.
-Igal Corcos




_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com






More information about the jdom-interest mailing list