I'm attempting to parse the value of @id from inside an xPath expression like:
"/hrdg:data/hrdg:meeting[@code='30J7Q']/hrdg:event[@id='2545525']/hrdg:selection[@id='31192111']"
I have written this regular expression, and am using thefollowing code for matching:
Pattern selectionIdPattern = Pattern.compile(".*/hrdg:selection[@id=\'(\\d+)\'].*");
// Grab the xPath from the XML.
xPathData = // Loaded from XML..;
// Create a new matcher, using the id as the data.
Matcher matcher = selectionIdPattern.matcher(xPathData);
// Grab the first group (the id) that is loaded.
if(matcher.find())
{
selectionId = matcher.group(1);
}
However selectionId does not contain the value after @id=.
Example of Desired Outcome
For example, with the above statement, I want to get:
"/hrdg:data/hrdg:meeting[@code='30J7Q']/hrdg:event[@id='2545525']/hrdg:selection[@id='31192111']"
Data I want: 31192111