cancel
Showing results for 
Search instead for 
Did you mean: 

XML String to XML conversion

Former Member
0 Kudos

Hi Folks,

I have to map an XML string to XML document. I am taking the XML string in to a source field and trying to map that to an XML structure. Sender message will be something like the following


  <?xml version="1.0" encoding="UTF-8" ?> 
- <ns0:mt_edi850 xmlns:ns0="http://test.com/xi/test/EDIOut">
- <EDI850>
- <EDIOutXML>
- <![CDATA[ <POAcknowledgement><ARNumber>0002000017</ARNumber><DocumentType>855</DocumentType><StatusReportDate>06/16/10 15:25:29</StatusReportDate><VendorNumber/><ContractNumber/><DepartmentNumber>DEPARTMENT</DepartmentNumber></POAcknowledgement>
   
  
  
  

]]>

The target message that I would like to map to is as follows


  <?xml version="1.0" encoding="UTF-8" ?> 
- <POAcknowledgement>
  <ARNumber>0002000017</ARNumber> 
  <DocumentType>855</DocumentType> 
  <StatusReportDate>06/16/10 15:25:29</StatusReportDate> 
  <VendorNumber /> 
  <ContractNumber /> 
  <DepartmentNumber>DEPARTMENT</DepartmentNumber> 
  </POAcknowledgement>

It is basically unwrapping the XMLdata i,e present in the CDATA tag. Is it possible to achieve the above using graphical mapping if so how, if not what are the other ways to achieve. Please advice.

Thanks,

Balaji

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

may b give a try to this

create a target node <POAcknowledgement>

Map <EDIOutXML> to the above node using the substring function so that u remove the prefix <POAcknowledgement> and suffix </POAcknowledgement>

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks a lot guys !

I followed the the link provided by Abhishek and used the code provided by Satish in that thread.

Link :[]

Thanks,

Balaji

former_member200962
Active Contributor
0 Kudos

Similar question answered here: .....the code given by Satish

Regards,

Abhishek.

Former Member
0 Kudos

Hi

You can use REGEX in UDF to parse/extract the xml content

Import : java.util.regex.*;

Parameter: content



String newContent;
String pattern = "(<ARNumber>)(.*)(</ARNumber>)"; 
// Create a Pattern object
Pattern d = Pattern.compile(pattern);
// Now create matcher object. 
Matcher m = d.matcher(content);
if (m.find( )) { 
 newContent = m.group(2);
}

return newContent;

Graphical mapping

Source---> UDF --> Target

Regards

Ramg