Hi Ishwari,
For Taking exact XML portion you can use the below Xpath function,
substring( $XMLEntityName ,find($XMLEntityName,'<ESADout_CUCustomsPaymentCalculation>')
findLast($XMLEntityName,'</ESADout_CUCustomsPaymentCalculation>'))
After finding exact list value string adjust the string as per XML format then you can simply do an export with mapping (store as string). The mapping can be based on a Message Definition (Go with Exact format what you needed in XML Schema) from your entity.
Hope it helps!
Thanks & Regards,
Manikandan K
Hi,
we had a similar requirement to extract data between two html tags, I created Js action for same it gives answer in numbering if multiple , pass your data and tag name
i checked with your data it is working
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";
// BEGIN EXTRA CODE
// END EXTRA CODE
/**
* @param {string} data
* @param {string} tag
* @returns {Promise.<string>}
*/
export async function HTML_Extractor(data, tag) {
// BEGIN USER CODE
const startTagPattern = `<${tag}`;
const endTagPattern = `</${tag.split(" ")[0]}`;
let resultString = "";
let startIndex = 0;
let count = 1; // Initialize a counter for numbering
while (true) {
startIndex = data.indexOf(startTagPattern, startIndex);
if (startIndex === -1) break;
startIndex = data.indexOf('>', startIndex);
if (startIndex === -1) break;
startIndex += 1;
const endIndex = data.indexOf(endTagPattern, startIndex);
if (endIndex === -1) break;
const content = data.substring(startIndex, endIndex).trim();
resultString += `${count}) ${content} \n`; // Concatenate content with numbering
count++; // Increment the counter
startIndex = endIndex + endTagPattern.length;
}
if (resultString === "") {
console.error(`No content found between <${tag}> and </${tag.split(" ")[0]}> tags.`);
return ""; // Return an empty string if no content is found
}
return resultString.trim();
// END USER CODE
}
Ishwari,
Another way to do this is with Mendix string functions. If the incoming XML will potentially have a different structure each time, this is how I would do this. I created a sample microflow, shown below:
Note that I have logged the results to the console. You could also put these results into an entity.
When I called this microflow with the following sample data:
These results displayed in the console
Hope that helps,
Mike