cancel
Showing results for 
Search instead for 
Did you mean: 

Select XML element by XPath

nicola_martella2
Participant
0 Kudos

Hi people.

I need to reference a receiver determination via XPath using an element in the inbound XML. The XML is like this:


<?xml version="1.0" encoding="utf-8"?>
<ns0:MT_Marked xmlns:ns0="http://test/nick">
  <row>
    <A>field1</A>
    <Mark>X</Mark>
  </row>
  <row>
    <A>field2</A>
    <Mark></Mark>
  </row>
  <row>
    <A>field3</A>
    <Mark></Mark>
  </row>
</ns0:MT_Marked>

The element basing of the receiver is determined, is the <Mark> element child of the first <row> element.

The correct XPath query should be


/ns0:MT_Marked/row[1]/Mark = X

or

/ns0:MT_Marked/row[1]/Mark = 'X'

not multilined.

In the prefix table, I have defined


ns0=http://test/nick

Unfortunately, at runtime the PI seems ignores the query.

Please, what's wrong in my approach?

Thanks in advance.

Ciao. Nicola

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi Nichola,

Have you tried /ns0:MT_Marked/row[1]/Mark = 'X' with multiline checked in receiver determination condition?

Regards

Suraj

nicola_martella2
Participant
0 Kudos

Thanks for your instantaneous support )

I tested


/ns0:MT_Marked/row/Mark = X 

without [1] and


/ns0:MT_Marked/row[1]/Mark = X 

with multiline check but without news.

The exact configuration in my receiver determination is the follow


/ns0:MT_Marked/row/Mark != X     EX   : --> comm_comp_1
/ns0:MT_Marked/row/Mark = X     EX   : --> comm_comp_2

I tried too


/ns0:MT_Marked/row/Mark != X        : --> comm_comp_1
/ns0:MT_Marked/row/Mark = X         : --> comm_comp_2

using the graphical operator by Condition Editor.

I'm hoping in you

Nicola

former_member187339
Active Contributor
0 Kudos

Hi Nicola,

try this



/ns0:MT_Marked/row[0]/Mark != X     EX   : --> comm_comp_1
/ns0:MT_Marked/row[0]/Mark = X     EX   : --> comm_comp_2

OR



/ns0:MT_Marked/row[0]/Mark != 'X'     EX   : --> comm_comp_1
/ns0:MT_Marked/row[0]/Mark = 'X'     EX   : --> comm_comp_2

Regards

Suraj

nicola_martella2
Participant
0 Kudos

Great Suraj !!!!

I was very near and I didn't saw the solution )

Thank you very much Suraj.

Ciao. Nicola

former_member187339
Active Contributor
0 Kudos

Hi Nicholas,

Welcome!!!

Yes sometimes we miss, even though it's in front of us :):)

-Suraj

Answers (1)

Answers (1)

prateek
Active Contributor
0 Kudos

Have you simply tried this?

>>/ns0:MT_Marked/row/Mark = X

Regards,

Prateek