on 10-11-2007 4:44 PM
how to exteract the particular field from the given string:
ProcessEmp this element has a below string subfields.
<ProcessEmp><?xml version="1.0" encoding="utf-8" standalone="no"?>
<Employee PersonnelNumber="11111" FirstName="String" MiddleName="String" LastName="String" Department="String" Group="" SapUserID="10flname" EmailAddress="flname@mu.edu" DefaultPassword="*" Status="Success" /></ProcessEmp>
how to extract only PersonalNumber, department, EmailAddress from above ProcessEmp into 3 diff fields.
Thanks
dhanush.
Hi,
You are receiving XML message within a field. To access a particular field from that XML message, you could create a User Defined Function, as suggested by many already.
You could write UDF using some of the String operation functions. This could include following:
1. If you need to access field Employee PersonnelNumber, you could get last index of that within string using function lastIndexOf(String str). Pass string "Employee PersonnelNumber="" for this function.
2. This function would return an index of rightmost occurance of this string.
3. after this you could get the index of next occurance of ", as the value of field is within quotes. You could use function indexOf(int ch, int fromIndex) for getting the same. You would pass Character as " and index as the one received by previous function.
4. Now you have index for starting and ending point of value string for desired field.
5. After this you could use substring(int beginIndex, int endIndex) function by passing first and second index values to retrieve the needed string, which contains value of field.
Hope this would be helful.
Thanks,
Bhavish
Reward points if comments found helpful:-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> ProcessEmp this element has a below string
> subfields.
>
> <ProcessEmp><?xml version="1.0" encoding="utf-8"
> standalone="no"?>
> <Employee PersonnelNumber="11111"
> FirstName="String" MiddleName="String"
> LastName="String" Department="String" Group=""
> SapUserID="10flname" EmailAddress="flname@mu.edu"
> DefaultPassword="*" Status="Success"
> /></ProcessEmp>
As u mentioned the XML messaeg is coming in the ProcessEmp element. so in ur mapping this will simply act as a string and u have to perform manipulation on it to get the expected values.
so just write a UDF and return the value from it.
example:
source = ProcessEMP
target = PN (where u have to map the value of the PersonalNumber.)
so just write a UDF which will accept that whole String and return only 1111.
What u have mentioned is just a String which look like a XML message..but u cannot map the fields directly...
Thanks
Farooq.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dhanush,
As I said earlier U will have to do the following
1.) In the mapping create a user defined funtion
2.) In the pop up box give a name to ur function like ExtractEmpNo
this should be of the type Value.
3.) Then in the code section write the following simple code
String result[] = a.split("\"");
return result[7];
4.) keeping it simple spliting with " sign , so u have to either calculate the
number of " before Personnel number Or
5.) u can improvise the code if U like it to be more generic
else for retireving rest of the field values simple just calculate
Get back if U have any issues.
Regards
Kavitha
Dhanush,
The parameters which you have given inside the employee node are Attributes of the employee. In this case map the attributes you needed to the target structure directly. It will solve your issue.
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
when i imported WSDL ProcessEmp, it does not showing attributes under ProcessEmp, it just shoing ProcessEmp witch will have below string.
ProcessEmp this element has a below string subfields.
<ProcessEmp><?xml version="1.0" encoding="utf-8" standalone="no"?>
<Employee PersonnelNumber="11111" FirstName="String" MiddleName="String" LastName="String" Department="String" Group="" SapUserID="10flname" EmailAddress="flname@mu.edu" DefaultPassword="*" Status="Success" /></ProcessEmp>
how to extract only PersonalNumber, department, EmailAddress from above ProcessEmp into 3 diff fields.
Hi Dhanush
It seems ur getting this XML inside another element
also if Ur using Graphical Mapping
then :
1.) Create a new User Defined Funtion.
2.) Use String Tokenizer with equals sign ("=")
3.) and collect the values into variables.
Regards
Kavitha
Message was edited by:
Kavitha Golagani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how you have your source structure?
did you import any XSD for that?looks like ,mentioned fields are attributes.
>>how to extract only PersonalNumber, department, EmailAddress from above ProcessEmp into 3 diff fields
just map from source to target fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.