简体   繁体   English

从jPOS ISO提取元素值

[英]Extracting Element Value from jPOS ISO

I am trying to extract a value within an ISO String which I get from a jPOS Structured Data. 我正在尝试从jPOS结构化数据中获取ISO字符串中的值。 The string looks like this: 该字符串如下所示:

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

Is there a way I can get the value "1111111111" of ReferenceId node? 有没有一种方法可以获取ReferenceId节点的值“ 1111111111”?

The sample data is a postilion structured data field which uses kind of a TLV (tag length value format). 样本数据是使用TLV(标签长度值格式)类型的后构结构数据字段。

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

221ThirdPartyBillPayment

Here 2 is the length of length (21), 21 is the length of the tag ThirdPartyBillPayment 这里2是长度(21)的长度,21是标记ThirdPartyBillPayment的长度

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

Here 3 is the length of length (125), 125, is the length of data to follow. 3是长度(125)的长度,125是要跟随的数据的长度。

You could write code to get access to xml iteratively for all thats available in structured data and then parse out the xml data within. 您可以编写代码来迭代访问结构化数据中所有可用内容的xml,然后解析其中的xml数据。 Or You could ask Postilion for the dtd/schema for the xml used in their structured data iso field and use jaxb to access the data. 或者,您可以要求Postilion提供其结构化数据iso字段中使用的xml的dtd / schema,然后使用jaxb访问数据。

It will boil down to a name value pair 它将归结为一个名称值对

ThirdPartyBillPayment= <ThirdPartyBillPayment><BillPaymentRequest<ReferenceId>1111111111</ReferenceId></BillPaymentRequest>
</ThirdPartyBillPayment>

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, ie: 您已经在一些固定字段和一些XML的混合中得到了一些自定义数据,因此首先需要从ISOMsg中获得整个字段,即:

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 . 然后找出XML的起始位置(在本例中为indexOf('<') ),然后需要在XML解析器中提供该XML(可以使用jPOS依赖项中的jdom ),解析XML并获取XML。子元素ReferenceId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM