Solved

xPath Syntax

Posted on 2013-10-30
2
170 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

860 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