cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH Expression in General Splitter

markbernabe
Active Participant
0 Kudos

Hi Experts,

I have the following XML

<root>
	<element>
		<url>https://www.google.com</url>
		<status>NOTOK</status>
	</element>
		<element>
		<url>https://www.facebook.com</url>
		<status>OK</status>
	</element>	
</root>

And I would like to use the following XPath Expression (/root/element[status/text() = 'OK']/url) in the General Splitter

However, I'm getting an error about the limitation of the XPath Expression.

I also tried using Header and Property from Content Modifier but I'm still getting the same problem.

Is there any workaround for this aside from the split in Message Mapping?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Mark.

You can leverage Content Filter in this case.

Regards,

Sriprasad Shivaram Bhat

markbernabe
Active Participant
0 Kudos

Thanks Sriprasad! Good to know.

Just having a tough time now rebuilding the XML because the result of filter is just the URLs

<url>https://www.google.com</url> <url>https://www.facebook.com</url>

Answers (2)

Answers (2)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Mark,

I have also tried it its not removing element below are the details ( Could you please check your filter condition )

Input XML:

<root>
    <element>
        <url>https://test.com</url>
        <status>OK</status>
    </element>
    <element>
        <url>https://mail.test.com</url>
        <status>NOTOK</status>
    </element>
    <element>
        <url>https://tester.com</url>
        <status>OK</status>
    </element>
    <element>
        <url>https://eree.tr.com</url>
        <status>NOTOK</status>
    </element>
</root>

Filter Condition:

 /root/element[status/text()='OK']

Content Modifier:

<root>
${in.body}
</root>

Output:

<root>
    <element>
        <url>https://test.com</url>
        <status>OK</status>
    </element>
    <element>
        <url>https://tester.com</url>
        <status>OK</status>
    </element>
</root>

Regards,

Sriprasad Shivaram Bhat

markbernabe
Active Participant
0 Kudos

Hi Sriprasad,

My bad! Got another XPath Expression. Sorry 🙂

Thanks again!

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Mark,

Rebuilding is very simple after Filter add Content Modifier something like below in Body since Filter removes only <root> element.

<root>
${in.body}
</root>

Regards,

Sriprasad Shivaram Bhat

markbernabe
Active Participant
0 Kudos

Hi Sriprasad,

The Filter removes <element> and it becomes

<root>
	<url>http://www.foo.com</url>
	<url>http://www.google.com</url>
</root>