Solved

xPath Syntax

Posted on 2013-10-30
2
167 Views
Last Modified: 2013-11-14
Hello,

We have a program that recently allowed us to use Xpath to conditionally set a value to a field

I want to put in an if statement that says If this element contains *VIP* set the value to a text string.  This is what i have currently and the xml which is not working.  The () at start and finish are required

(if //Profile/Traveler/TPA_Extensions/PriorityRemarks[contains(@Text, "*VIP*'')] then "S*UD5 VIP"   else "")

<Profile CreateDateTime="2013-10-03T19:09:42.399Z" UpdateDateTime="2013-10-25T19:50:16.059Z" PrimaryLanguageIDCode="EN-US">
  <TPA_Identity ClientCode="TN" ClientContextCode="MYS" UniqueID="105558622" ProfileTypeCode="TVL" ProfileName="NEVER WILLIAM" ProfileNameModifyIndicator="Y" ProfileDescription="" DomainID="AAAA" ProfileStatusCode="AC"/>
  <Traveler>
    <TPA_Extensions>
      <PriorityRemarks Text="*** VIP ***&amp;#10;other priority remarks...remark type PRIORITY" OrderSequenceNo="1"/>
    </TPA_Extensions>
  </Traveler>
  <Association AssociationID="36812" DomainID="A98A" ClientCode="TN" AssociationDescription="A98A Traveler Profile Template" AssociationName="A98A Traveler Profile" ClientContextCode="MYS" ProfileTypeCode="TVL" CreateDateTime="2013-10-03T19:00:07.312Z" UpdateDateTime="2013-10-25T19:51:24.157Z"/>
</Profile>

any thoughts?
0
Comment
Question by:posae
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39613551
Without knowing the exact way that particular program handles the 'xpath check' code it's hard to say where the problem is, but 2 general remarks:

1) the check code contains a strange problem concerning the use of 2 single quotes rather than a double quote after the text to check:

[contains(@Text, "*VIP*'')]

Open in new window


2) if the stars (asterix) are meant to be wildcards, leave them out for the contains function to work. If they are meant to be a part of the text literally, note that the example xml has spaces around VIP whereas the check does not:
*** VIP ***

Open in new window

and checking for:
*VIP*

Open in new window

0
 

Author Closing Comment

by:posae
ID: 39647655
Thanks...the quotes were the issue
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now