Kourier Integrator Online Help

Import XML XPath Expressions

Kourier uses XPath expressions to map the elements and attributes of an XML document into the fields entered into an Import Specification. You may also programmatically process XPath expressions using the Kourier UniBASIC function XML.XPATH.

In Kourier, node names and attributes names are processed in a case insensitive way. For example, in the XML document shown below an XPath of NAME or NaME or name will return the data value associated with the NAME element.

Kourier supports the following XPath syntax: 

Parameter

Description

node_name

Selects all elements with node_name and returns the data value of that element

@attribute_name

Selects attributes of an element with a node_name and returns the value of the attribute

@DESC='Home3'

Selects attributes of an element with a node_name and returns the data value of that element if the attribute value equals the string specified. The string specified is evaluated in a case sensitive way.

/

Node path divider

,

Node path divider.

[n]

Used to indicate which occurrence of a node_name to process

[@attribute_name='val']

Used to find an occurrence of an attribute with a specific value. The equals operator is the only operator supported at this time.

Consider the following XML code:

<?xml version=”1.0” ?> 
 
< ADDRBOOK > 
      < ENTRY ID =" id1 "> 
         < NAME > Name One </ NAME >  
         < ADDRESS > 101 Some Way </ ADDRESS >  
         < PHONENUM DESC =" Work1 "> 303-111-1111 </ PHONENUM >  
         < PHONENUM DESC =" Fax1 "> 303-111-2222 </ PHONENUM >  
         < PHONENUM DESC =" Pager1 "> 303-111-3333 </ PHONENUM >  
         < EMAIL > name.one@some.com </ EMAIL >  
      </ ENTRY >  
        < ENTRY ID =" id2 ">  
         < NAME > Name Two </ NAME >  
         < ADDRESS > 202 Some Way </ ADDRESS >  
         < PHONENUM DESC =" Work2 "> 303-222-1111 </ PHONENUM >  
         < PHONENUM DESC =" Fax2 "> 303-222-2222 </ PHONENUM >  
         < PHONENUM DESC =" Home2 "> 303-222-3333 </ PHONENUM >  
      </ ENTRY >  
        < ENTRY ID =" id3 ">  
         < NAME > Name Three </ NAME >  
         < ADDRESS > 203 Some Way </ ADDRESS >  
     < PHONENUM DESC =" Work3 "> 303-333-1111 </ PHONENUM >  
         < PHONENUM DESC =" Fax3 "> 303-333-2222 </ PHONENUM >  
         < PHONENUM DESC =" Home3 "> 303-333-3333 </ PHONENUM >  
         < EMAIL > name.three@some.com </ EMAIL >  
   </ ENTRY >  
</ ADDRBOOK > 

The following XPath expressions would yield the following data:

XPath Expression

Returns (| is used as a delimiter to improve readability)

NAME

Name One | Name Two | Name Three

ENTRY@ID

id1 | id2 | id3

ADDRBOOK/ENTRY[1]/ADDRESS

101 Some Way

ADDRBOOK/ENTRY[2]/PHONENUM[1]

303-222-1111

ADDRBOOK/ENTRY/EMAIL

name.one@some.com | name.three@some.com

ADDRBOOK/ENTRY/PHONENUM[@DESC='Home3']

303-333-3333