Skip to Content
0

XPATH Expression in General Splitter

Jan 25, 2017 at 08:18 AM

155

avatar image

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!

xpath.png (15.0 kB)
error.png (4.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Sriprasad Shivaram Bhat Jan 25, 2017 at 08:58 AM
0

Hello Mark.

You can leverage Content Filter in this case.

Regards,

Sriprasad Shivaram Bhat


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Sriprasad! Good to know.

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

https://www.google.com https://www.facebook.com

0
Sriprasad Shivaram Bhat Jan 25, 2017 at 12:32 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Sriprasad,

The Filter removes <element> and it becomes

<root>
	<url>http://www.foo.com</url>
	<url>http://www.google.com</url>
</root>
0
Sriprasad Shivaram Bhat Jan 26, 2017 at 07:28 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Sriprasad,

My bad! Got another XPath Expression. Sorry :)

Thanks again!

0