@id
次のような式の中から fromの値を解析しようとしていますxPath
:
"/hrdg:data/hrdg:meeting[@code='30J7Q']/hrdg:event[@id='2545525']/hrdg:selection[@id='31192111']"
私はこの正規表現を書き、マッチングのために次のコードを使用しています:
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);
}
ただしselectionId
、 の後の値は含まれません@id=
。
望ましい結果の例
たとえば、上記のステートメントで取得したいのは次のとおりです。
"/hrdg:data/hrdg:meeting[@code='30J7Q']/hrdg:event[@id='2545525']/hrdg:selection[@id='31192111']"
Data I want: 31192111