How to capture [element contents] in XML Extract or else?

Hi Master,

With “XML Extract” how can I treat the [element contents] under element in ex1 as the same as in ex2?

ex1:


DEFINE1


DEFINE2

ex2:


DEFINE1


DEFINE2

In another word, how could I get the structured data once transforming ex1 into Clover metadata as below?

Key Attribute
alpha DEFINE1
beta DEFINE2

I tried to map that [element contents] to a Clover Field in “Mapping” tab of “XML Extract”, but the values in the result are null, I assume that in general all the elements included in <> need be predefined to make them identified. Is there any possibility to escape this criterion at such XML level?

I will appreciate any of your ideas or workaround solutions.

Thanks,

Hi evanchen,

what you want is directly not possible. I would recommend to do some kind of xml text preprocessing. You can:

1] remove unwanted elements “” and “” (eg. by CTL2 function ‘replace(orig, “”, “”)’)
2] somehow escape XML control characters of unwanted elements (eg. by CTL2 function ‘replace(orig, “”, “<definition>”)’)

Then it will be readable by XmlExtract as you want.

Hi Jaroslav,

Thanks again for you support, actually my case is more complicated than I mentioned in the previous example. my current case is as below:

ex:


DEFINE1
ATTRIBUTE1
METRIC1


DEFINE2
ATTRIBUTE2
METRIC3

and I need to keep those blue values entirely in the output port, do you know if other component such as XSLTransformer and XMLXPathReader can work for this request? if so, any examples?

Hi evanchen,

Please take a look on attached graph, try to debug in and observe values on edges.

Hello Jaroslav,

Thanks for your example!

I had thought out the similar approach, but your CTL2 code seems more elegant. :smiley: