I have a string, which could look like this:
"Sandra <as type="1">walked</as> in the park, and met a <as type="3">random</a> stranger".
Based on these xml tags, I would like to replace the tag with something else (a list of controls).
For instance, when I see <as type="1">walked</as> , I want to return a literal and a textbox to be replaced in that sentense.
I guess the simplest way would be to add the whole thing in a placeholder, but I’ve no idea how to do the replacement part.
You currently don’t have valid XML, so as a first step I recommend you surround it with some basic tags, for example:
Now we can parse it:
Now we have two types of nodes in this XML – Text and Elements. You can easily loop through any number of ways and extract them, change them, do what you like. Here’s an example:
This will print: