Skip to main content
All CollectionsMapping ManagerxPath
xPath - Building xPath with Mapping Manager
xPath - Building xPath with Mapping Manager
Micah A. Parker avatar
Written by Micah A. Parker
Updated over a month ago

Product: Mapping Manager


At this time only TrueCommerce Support can define xPath

Please Contact Support


Creating an xPath Token


Creating an xPath Token is similar to that of creating a standard token within Mapping Manager - you simply just need to add the xPath Query to the token definition in order to have it generate the values based off of the xPath Result rather than an XML Element itself.

Navigate: Entities โ†’ (Entity)

Select: Edit

Select: Values (tab)

Creating a Token

Within the Values screen you can create a token utilizing the New or Insert button on the light-blue bar - and then entering your xPath Query within the labeled column.

Select: New

Fill: xPath Query

Select: Save

it's recommended to prefix the label with TC_ to indicate this is a TrueCommerce Generated token rather than apart of the XML directly

Note: You may need to scroll the columns list to see the xPath Query option


Understanding Pathing within Mapping Manager


While you can create an xPath Token anywhere within the Entities Definition - you will need to keep in mind that Mapping Manager pre-builds the xPath based on the row entry the token was created under.

As such you will need to define your pathing to access data accordingly based on the hierarchy of where the xPath Token is starting relative to the data you're attempting to access.

Definition Hierarchy

The left-hand XML schema hierarchy is presented whenever under the Values screen where you can easily see how your XML is formatted - seeing the Parent and Child relationship at a glance.

Each of these rows within the definition determine how the XML needs to be structured, and allows you to see what the relationship between other rows are to determine your pathing structure.

Example

Using the selected Header as an example any xPath Query defined as a token within the Header row will start its path from within the Header XML (Invoice/Header)

Looking at the below XML Sample File you can see that our xPath Query would start within the Header Element group and as such - will need to be treated relative to that selection.

Example XML

<Invoice>

<Header> <----xPath Starts Here

<InvoiceNumber>123456</InvoiceNumber>

<InvoiceDate>2024-10-21</InvoiceDate>

<PurchaseOrderNumber>PO987654</PurchaseOrderNumber>

<VendorID>V123456</VendorID>

<CustomerID>C789012</CustomerID>

<PaymentTerms>Net30</PaymentTerms>

<Addresses>

<BillTo>

<Name>Customer Name</Name>

<Address1>123 Billing St.</Address1>

<City>Billing City</City>

<State>CA</State>

<PostalCode>90001</PostalCode>

<Country>USA</Country>

</BillTo>

<ShipTo>

<Name>Customer Name</Name>

<Address1>456 Shipping St.</Address1>

<City>Shipping City</City>

<State>CA</State>

<PostalCode>90002</PostalCode>

<Country>USA</Country>

</ShipTo>

</Addresses>

</Header>

<Items>

<Item>

<ItemNumber>1</ItemNumber>

<Description>Item Description 1</Description>

<Quantity>10</Quantity>

<UnitPrice>15.00</UnitPrice>

<TotalPrice>150.00</TotalPrice>

</Item>

<Item>

<ItemNumber>2</ItemNumber>

<Description>Item Description 2</Description>

<Quantity>5</Quantity>

<UnitPrice>20.00</UnitPrice>

<TotalPrice>100.00</TotalPrice>

</Item>

</Items>

</Invoice>

Selecting Items

If we wanted to select nodes from within the Items group for example - we would need to be sure to first traverse up the XML back into the Invoice group before selecting our items.

Path to <Items> from <Header>

../Items

<Items>

<Item>

<ItemNumber>1</ItemNumber>

<Description>Item Description 1</Description>

<Quantity>10</Quantity>

<UnitPrice>15.00</UnitPrice>

<TotalPrice>150.00</TotalPrice>

</Item>

<Item>

<ItemNumber>2</ItemNumber>

<Description>Item Description 2</Description>

<Quantity>5</Quantity>

<UnitPrice>20.00</UnitPrice>

<TotalPrice>100.00</TotalPrice>

</Item>

</Items>

rev 10/17/2024

Did this answer your question?