Xpath question

Questions about XML that are not covered by the other forums should go here.
Raymond
Posts: 1

Xpath question

Thu Dec 28, 2017 4:55 pm

I have an XML document that contains elements in one node GROUP that have attributes CLIENTID, LAST_NAME, FIRST_NAME and PREFIX_NAME. In another node CASESTEP are attributes CLIENTNAME and SCHOOLNAME. The CLIENTNAME consists of "PREFIX_NAME LAST_NAME, FIRST_NAME". For example my own name: "Van Erkel, Raymond".

Is there a way to use XPATH to search my XML file for the CLIENTID based upon the occurence of FIRST_NAME (in the one note) in CLIENTNAME (in the other note)? Also for the SCHOOLNAME. I dont't want to show the CLIENTIDs of all GROUP MEMBERS.

In the example below I want to have '123' as the result of the occurence of 'Raymond' in 'Van Erkel, Raymond'. Also 'Abc' as the result for SCHOOLNAME.

-<GROUP>
-<MEMBER>
<CLIENT_ID>123</CLIENT_ID>
<FIRST_NAME>Raymond</FIRST_NAME>
<LAST_NAME>Erkel</LAST_NAME>
<PREFIX_NAME>van</PREFIX_NAME>

-<CASESTEP>
<QUESTION_321_CLIENTNAME>Van Erkel, Raymond</QUESTION_321_CLIENTNAME>
<SCHOOLNAME>Abc</SCHOOL>

I tried contains and substring_after functions but I can't get it to work. Please help me out.
Radu
Posts: 5213

Re: Xpath question

Wed Jan 03, 2018 2:29 pm

Hi,

I'm not sure I understand your entire use case, maybe you can try an XPath like this:

Code: Select all

//CLIENT_ID[contains(following-sibling::FIRST_NAME/text(), 'Raymond')]


Also as this is a generic XPath/XSLT question you have the option to write on StackOverflow about it, it's a larger community and on the Oxygen forum notifications for newly started threads are only received by us (the moderators).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 2 guests