on 02-04-2009 3:55 PM
Dear All
One of my scenarios receive a payload in the following format
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_String xmlns:ns0="http://scb.com/xi/payment/10">
<person>name=John&lastname=Smith&city=ny&country=USA&zip=®ion=Americas</person>
</string_MT>
</ns0:MT_String>
I am trying to split the <text> parameter & delimited into a new structure that will look as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_String_split xmlns:ns0="http://hr.com/">
<person>
<name>John</name>
<lastname>Smith</name>
<city>ny</city>
<country>USA</country>
<zip></zip>
<region>Americas</region>
</person>
</ns0:person>
Can somebody please advise that how this can be done?
Will grant highest point for the coplete answer.
Thank you
Haik
Hi,
you have to build a UDF to achieve this.
2 inputs: the complete string and the variable name (e.g. name)
1 output: the value
You could user java regular expressions and define that the value you are looking for is always after the "variable name" and always before a & or a <.
Kind Regards,
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Haik,
it should look more or less like this:
import java.util.regex;
String strRegex;
String strOpenTag;
String strCloseTag;
int lenOpenTag;
int lenCloseTag;
strOpenTag = your_variable_name;
srtCloseTag = "[&|<]";
lenOpenTag = strOpenTag.length();
lenCloseTag = strCloseTag.length();
strRegex = strOpenTag + ".*" + strCloseTag;
Pattern p = Pattern.compile(strRegex);
Matcher m = p.matcher(your_xmlStringInput);
while(m.find()){
return your_xmlStringInput.substring(m.start()+lenOpenTag ,m.end()-lenCloseTag);
}
return "error";
Ciao,
Sergio
Also you can look at the SAP XI wiki at
https://www.sdn.sap.com/irj/scn/wiki
and look for " How to append Carriage Return in the end of each tag of xml file "
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.