Xpath question
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 1
- Joined: Thu Dec 28, 2017 4:49 pm
Xpath question
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.
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.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Xpath question
Hi,
I'm not sure I understand your entire use case, maybe you can try an XPath like this:
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
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')]
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service