This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is there a way to compile an xpath expression and return a "String" based on the result ? Meaning, say I compile the following xpath expressions:
I want to compile each of the above strings in a condition and return "Package", "Libapp", "Module" respectively if the xpath expression is found in the given XML.
I used the following code to achieve this: (target is the XML passed when the getEntryType method is called)
This code works. But, I am wondering if there is a simpler way to do it? Something like if "expression" compiled true return "String". I remember seeing something like this ( "[./libx:package]\"Package\" )somewhere but not sure of it is right.