Reputation: 1336
i have this String and i need to get the attribut Ccy to TtlIntrBkSttlmAmt with a regex.
Can you help me to have the best pattern ?
<?xml version = "1.0" encoding = "UTF-8"?>
<Document xmlns = "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<FIToFICstmrCdtTrf>
<GrpHdr>
<MsgId>XXXXXXXXXXX</MsgId>
<CreDtTm>2013-07-23T16:30:14</CreDtTm>
<NbOfTxs>0</NbOfTxs>
<TtlIntrBkSttlmAmt Ccy = "EUR">0000.00</TtlIntrBkSttlmAmt>
<IntrBkSttlmDt>2013-07-24</IntrBkSttlmDt>
<SttlmInf>
<SttlmMtd>CLRG</SttlmMtd>
<SttlmAcct>
<Id>
<IBAN>XXXXXXXXXXXXXXXX</IBAN>
</Id>
</SttlmAcct>
<ClrSys>
<Prtry>XXXXX</Prtry>
</ClrSys>
</SttlmInf>
</GrpHdr>
Thank you.
Upvotes: 0
Views: 201
Reputation: 1336
?? = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse( new InputSource( new StringReader( XMLLine ) ) )
.getElementsByTagName("TtlIntrBkSttlmAmt")
.item(0).getAttributes().getNamedItem("Ccy").getNodeValue();
Upvotes: 1
Reputation:
I wouldn't use a Regex, use an XML parser instead. Anyway...
(?!= <TtlIntrBkSttlmAmt)Ccy = "[A-Z]+"
Should do the trick. Edit the [A-Z] group to meet your specific needs.
Upvotes: 1