Hello, My question concerns getting the name/value of attributes from an XPath. Consider the following:
@id mailingAddress/country mailingAddress/region timestamp[@type='added'] timestamp[@type='deleted'] I want to recreate an XML document based on the above, which means uniquely identifying elements and attributes. I've explored the org.jaxen.expr.* packages for some time and cannot find how to extract the "type" attribute (and its value) of the "timestamp" XPaths. Source snippet: BaseXPath xPath = // ... provided as a parameter ... LocationPath path = (LocationPath)xPath.getRootExpr(); Iterator nodes = path.getSteps().iterator(); while( nodes.hasNext() ) { DefaultNameStep step = ((DefaultNameStep)nodes.next()); System.out.println( step.getText() ); } The output from running the above code follows: attribute::id child::mailingAddress child::region child::mailingAddress child::country child::timestamp[(attribute::type = "added")] child::timestamp[(attribute::type = "deleted")] Great so far! How do I programically get the name/value of the "type" attribute for the "timestamp" elements? The input XML is basically: <?xml version="1.0"?> <document id="42"> <mailingAddress> <region>Ontario</region> <country>Canada</country> </mailingAddress> <timestamp type="added"> <year>2001</year> </timestamp> <timestamp type="deleted"> <year>2002</year> </timestamp> </document> And I can produce this (not-quite-identical) document, with a single "timestamp" element: <?xml version="1.0"?> <document id="42"> <mailingAddress> <region>Ontario</region> <country>Canada</country> </mailingAddress> <timestamp> <year>20012002</year> </timestamp> </document> Please Note: I only have the XPaths, the input XML is -not- available. I've tried the DefaultNameStep::getPredicates() method (in vain) to get the "type" attribute. The Step Interface documentation (and down the chain) is rather sparse, leaving me fumbling in the dark. Thanks in advance for any tips and/or solutions! Sincerely, Dave Jarvis _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest