0

jPOS 構造化データから取得した ISO 文字列内の値を抽出しようとしています。文字列は次のようになります。

221ThirdPartyBillPayment3125
<ThirdPartyBillPayment>
    <BillPaymentRequest>
        <ReferenceId>1111111111</ReferenceId>
    </BillPaymentRequest>
</ThirdPartyBillPayment>

ReferenceId ノードの値「1111111111」を取得する方法はありますか?

4

2 に答える 2

1

サンプルデータは、一種の TLV (タグ長値形式) を使用する postilion 構造化データ フィールドです。

221ThirdPartyBillPayment3125
<ThirdPartyBillPayment>
    <BillPaymentRequest>
        <ReferenceId>1111111111</ReferenceId>
    </BillPaymentRequest>

221ThirdPartyBillPayment

ここで、2 は長さ (21) の長さ、21 はタグ ThirdPartyBillPayment の長さです。

3125
    <ThirdPartyBillPayment>
        <BillPaymentRequest>
            <ReferenceId>1111111111</ReferenceId>
        </BillPaymentRequest>
    </ThirdPartyBillPayment>

ここで、3 は length (125) の長さ、125 は続くデータの長さです。

コードを記述して、構造化データで使用可能なすべてのデータに対して反復的に xml にアクセスし、その中の xml データを解析することができます。または、構造化データの iso フィールドで使用される xml の dtd/スキーマを Postilion に依頼し、jaxb を使用してデータにアクセスすることもできます。

名前と値のペアに要約されます

ThirdPartyBillPayment= <ThirdPartyBillPayment><BillPaymentRequest<ReferenceId>1111111111</ReferenceId></BillPaymentRequest>
</ThirdPartyBillPayment>
于 2016-08-18T04:34:07.773 に答える
0

You've got some custom data in a mix of some fixed fields and some XML there, so you first need to get the whole field off your ISOMsg, i.e:

String s = m.getString("127.1"); // provided your data comes in field 127.1

Then figure out where the XML starts (in this case, at indexOf('<')), then you need feed that XML in an XML parser (you can use jdom that comes as a jPOS dependency), parse the XML and get the child element ReferenceId.

于 2015-05-29T16:00:10.150 に答える