Yes. Of course I was using the wrong syntax to get a list of Attributes. This way I will get list of Attributes or Elements...I can test using instanceof whether to cast to Attribute or Element and problem solved. Thanks.
tcp -----Original Message----- From: bob mcwhirter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 19, 2002 10:59 AM To: Tom Preston Cc: [EMAIL PROTECTED] Subject: Re: [Jaxen] using [@name] inside of JAXEN On Tue, 19 Mar 2002, Tom Preston wrote: > While dynamically trying to retrieve an Attribute value using Jaxen...I find > that I have a problem. I have to "KNOW" within my program that I have > searched for an Attribute as opposed to an Element. This is because the > XPath selectNodes returns a list of Elements (using JDOM) that contain the > attributes instead of a list of Attributes. You can also get back a list of Attributes, if you use the right path. > I'm fine with it returning a list of Elements and think that this may often > be helpful since you know that you are free to cast the List elements into > JDOM Element instances. The problem that I have is that I have to know that > my "dynamic" xpath expression was ACTUALLY asking for Attributes of a > certain name...then I have to go thru the Elements returned and pick out the > values of the named attributes....this takes away from the dynamic nature of > the program (or causes me to have to know things that I wish JAXEN would > know for me). Or, rewrite your path... > XPath xpath = new XPath( "/TRIPS/TRIP/VACATION_ID[@name]"); Not certain exactly what you're looking to get, but this might do it: /TRIPS/TRIP/VACATION_ID/@name That'll return all name Attributes (actual org.jdom.Attribute objects) for your <VACATION_ID> elements. To get the Element itself, I think Attribute now has a getParent() call that returns the Element to which it is attached. -bob _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest