Skip to main content
Question

Get text from 1 element out of an XML attribute.

  • March 19, 2018
  • 3 replies
  • 14 views

Forum|alt.badge.img

Hi,

Quick question: I have a attribute containing a larger xml file. I need the text of one element as a new attribute. It's two levels deep. I tried messing around with the flattner but I can't get it to work.

Within the root, it looks like this:

<BG:gelijk StUF:entiteittype="NPS">

 

<BG:inp.bsn>*VALUE I NEED*</BG:inp.bsn>

 

</BG:gelijk>

Can someone help me out? Thanks!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Celebrity
  • 7843 replies
  • March 19, 2018

Hi @mvdorst, the XMLFlattener should work to extract the value of the <inp.bsn> element with these parameters.

  • Elements to Match: inp.bsn
  • Attributes to Expose: inp.bsn

However, it requires a premise that the XML namespaces (BG, StUF) are declared properly in the source XML document.


Forum|alt.badge.img
  • Author
  • 17 replies
  • March 19, 2018

I forget the expose part, thanks! What if I would want expose whatever is in

<BG:gelijk StUF:entiteittype="NPS">

with the name of inside element as attribute name, and the text as value. Is this possible? If not no problem, there are only a finite ammount of options, but it would save me manually check for each.


takashi
Celebrity
  • 7843 replies
  • March 19, 2018

I forget the expose part, thanks! What if I would want expose whatever is in

<BG:gelijk StUF:entiteittype="NPS">

with the name of inside element as attribute name, and the text as value. Is this possible? If not no problem, there are only a finite ammount of options, but it would save me manually check for each.

Exposing attribute name is optional, and it's necessary only if you need to refer to the attribute in the subsequent transformers or writer feature types when creating the workspace.

 

 

Would you like to use "NPS" as the name of attribute that stores "*VALUE I NEED*"?

 

If so, a possible way is to use the XMLXQueryExtractor.