4D Blog

Home Product Enhanced XPath Support

Enhanced XPath Support

May 13, 2020

Product

XPath is a language allowing you to easily work with your XML documents. It’s already usable via the DOM Find XML element command and with 4D v18 R3, the support of the XPath syntax has been drastically enhanced. If you’re among those who requested features such as using a wildcard in a path, then keep reading!

To use the new syntax with existing applications, you need to check the “Use standard XPath” compatibility setting. Newly created databases use the new syntax by default. You can now use new expressions such as //, @, *, last() to simplify your searches.

Examples of writing predicates 

We’ll use the following XML document in the examples below:

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
  <title lang="en">The Wheel of Time</title>
  <title lang="fr">La roue du temps</title>
  <price>29.99</price>
</book>
<book>
  <title lang="en">Harry Potter</title>
  <price>50.00</price>
</book>
<book>
  <title lang="en">Learning XML</title>
  <price>39.95</price>
</book>
</bookstore>
  • Find the next to last book element that is the child of the bookstore element:

$Dom_root2:=DOM Find XML element($Dom_root;"/bookstore/book[last()-1]";$arrAfound)
// Returns
//‹book›
// ‹title lang="en"›Harry Potter‹/title›
// ‹price›50.00‹/price›
//‹/book›

  • Find all the title elements that have a “lang” attribute with a value of “fr”:

$Dom_root2:=DOM Find XML element($Dom_root;"//title[@lang='fr']";$arrAfound)
// Returns ‹title lang="fr"›La roue du temps‹/title›

  • Find all the book elements that have a price equal to 39.95:

$Dom_root2:=DOM Find XML element($Dom_root;"book[price=39.95]";$arrAfound)</br />
// Returns
//‹book›
// ‹title lang="en"›Learning XML‹/title›
// ‹price›39.95‹/price›
//‹/book›

These are just a few examples of what you can do with the new expressions. You can mix them in a more or less complex way to find the results you need. Refer to the documentation to see what you can do with these new enhancements in more detail.

Discuss

Tags Compatibility settings, Programming, v18 R3, v19, XML

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy