Optimize AI Builder Data with XPath in Power Automate
Image Source: Shutterstock.com
Power Automate
Jan 23, 2024 8:30 PM

Optimize AI Builder Data with XPath in Power Automate

by HubSite 365 about Pieter Veenstra [MVP] (SharePains)

Microsoft MVP and Microsoft Productivity Principal Architect at HybrIT Services

Citizen DeveloperPower AutomateLearning Selection

Unleash Power Automates Potential: Harness AI Builder Data with XPath!

Key insights


AI Builder data is often used for extracting information from documents such as Invoices or Purchase Orders. Once a model is created, Power Automate processes the data to create records in systems like SharePoint or Dataverse.

The data structure can be complex to handle, and there can be a preference for a more user-friendly format. This desired format presents data as an array with easily identifiable field names, values, and display names rather than a single object with numerous properties.

To address complex data processing, the author suggests using XPath functions in Power Automate. They demonstrate converting AI Builder data into valid XML and then using XPath to process and manipulate the data effectively.

  • XPath assists in processing AI Builder data by allowing the extraction of specific information from the generated XML.
  • A manual trigger with AI Builder Data is used to start the process of converting data into valid XML with the JSON function.
  • Fetching field names from AI Builder data is done through XPath expressions, selecting top nodes to create an array of top-level nodes.
  • The "Apply to each" action is utilized to display data in nodes and build an object with the required properties such as fieldname and display name.
  • The final step involves collating these objects into an array for a more structured outcome, completing the data processing flow.

Processing Data with AI Builder and Power Automate

Integrating AI Builder with Power Automate enables businesses to harness the power of AI to automate complex data extraction processes. By utilizing models within AI Builder, users can extract data from a wide range of documents, streamlining the process of inputting this data into various systems such as SharePoint or Dataverse. This integration is highly beneficial for managing documents like Invoices or Purchase Orders, where structured data extraction is crucial.

The complexity of AI Builder data, with its intricate fieldnames and corresponding values, requires advanced processing techniques. XPath functions within Power Automate offer a solution to this challenge, providing methods to transform and query the data efficiently. Through XPath, users can extract and manipulate data fields, ensuring that the information is in a user-friendly format. The entire process revolves around creating valid XML from the data and using XPath to systematically extract necessary information. Ultimately, this method enhances the usability of the extracted data, making it compatible with various business applications, and improving automation workflows.

Today, we explore the process of managing AI-generated data, which can be quite intricate. AI technology is regularly harnessed to extract data from documents such as invoices or purchase orders. Utilizing AI modeling in conjunction with Power Automate streamlines the creation of records in platforms like SharePoint or Microsoft Dataverse.

The data retrieved from AI tools can be beneficial but may also present complexity in its raw form, particularly when dealing with fieldnames. Clients often prefer a more structured data format. This requires a flexible approach to handling fieldnames and displaying values as defined within the AI Builder, possibly involving a child flow for enhanced utility.

To address these challenges, understanding and manipulating data begins with utilizing the XPath function. The initial step is to convert AI generated data into a valid XML format, which can then be processed by the xml function. This transformation is achieved through specific code that turns a JSON object into XML data.

Once the AI Builder data is converted into XML, the focus turns to isolating the names of fields found within the data. This is accomplished by extracting the top nodes of the XML through an xpath expression. Following this, the array of top-level nodes is processed to extract the required information.

The processing method involves two main steps within an 'Apply to each' action. The aim is to construct an object that contains only the desired properties. This is where xpath expressions play a critical role in selectively obtaining fieldnames, values, and display names for each property.

Ultimately, the goal is to convert the collection of individual objects into a single, organized array. Leveraging a straightforward compose action, the assembled information forms the comprehensive flow needed to effectively process data derived from AI Builder.

While there may be potential for optimizing XPath operations, simplicity can be advantageous given the limitations of Power Automate’s xpath capacity in handling complex queries. Keeping the xpath expressions basic could therefore be beneficial.

  • Manage AI-generated data with efficiency
  • Easily process structured data from documents like invoices through Power Automate
  • Transform complex AI Builder data into a user-friendly format
  • Discover how to utilize XPath functions for effective data management
  • Turn JSON objects into XML for seamless processing
  • Extract necessary information through xpath expressions
  • Create streamlined arrays from raw xml data nodes
  • Optimize with simple xpath queries within Power Automate limitations


Read the full article Process AI Builder data using xpath in Power Automate


Understanding AI Builder Data Processing

AI Builder is a powerful component of the Microsoft 365 suite, enabling users to extract and process data from various documents. However, utilizing this tool requires understanding how to maneuver through complex data formats and convert them into a more structured form, compatible with different systems like SharePoint or Microsoft Dataverse. The blog post by Pieter Veenstra [MVP] (SharePains) highlights the intricate process of handling AI Builder data, illustrating the conversion of JSON to XML and navigating data extraction with XPath functions. Veenstra emphasizes the need for flexibility while dealing with dynamic fieldnames and stresses the importance of keeping XPath queries simple, ensuring compatibility with Power Automate's capabilities and aiming for seamless data flow construction.

Today, an inquiry regarding the dynamic data from AI Builder was raised for its efficient handling. AI Builder is often applied for document data extraction purposes, such as with Invoices or Purchase Orders. When developing a model within AI Builder, it can integrate with Power Automate to further process the gathered data.

The complexity of processing the data arises, specifically when dealing with intricate field names extracted by the AI Builder. Instead of working with convoluted data structures, a simpler format is often preferred by clients, featuring recognizable field names alongside their respective values and display names.

To address this challenge, one requires flexibility in managing field names, displaying values as defined within AI Builder, and potentially leveraging a child flow to allow for integration with other workflows. Commencing with AI Builder data processing, the XPath function offers significant utility, enabling the transformation of AI Builder data into valid XML for further manipulation.

  • The critical step involves converting the JSON AI Builder data into XML using the json() and xml() functions.
  • Subsequently, XPath expressions are employed to obtain the top-level nodes from the XML, providing an array of key data points.
  • To effectively navigate through this array, an apply-to-each step can be initiated, executing two distinct actions to render the desired data results.
  • In the final stage, the singular objects located are compiled into an array, simplifying the data representation and enhancing its manageability.

The methods discussed not only contribute to an efficient workflow but also simplify data processing. Despite limitations in XPath capabilities within Power Automate, the approach of maintaining simplicity offers substantial benefits.

Power Automate - Optimize AI Builder Data with XPath in Power Automate



People also ask

How to use XPath in Power Automate?

Using XPath in Power Automate enables users to navigate through XML documents, allowing them to select nodes or node-sets. XPath expressions can also be used with HTML documents. Power Automate leverages the 'Parse XML' action to process the XML document, after which you can employ the 'Compose' action to apply the XPath queries for the required data extraction.

How does AI builder work in Power Automate?

AI Builder in Power Automate is a platform feature that allows users to add artificial intelligence to workflows. It offers pre-built AI models, like form processing, object detection, and text classification, which can be trained with your data. Users can easily integrate these models into their flows within Power Automate, empowering their apps with AI capabilities to automate complex tasks.

Where does AI Builder store data?

AI Builder stores the data used for model training and analysis in the Common Data Service (CDS), which is now a part of Microsoft Dataverse. This secure platform ensures data integrity and allows for easy data management, as well as integration with Power Apps, Power Automate, and Dynamics 365 applications.

What is document classification using Power Automate?

Document classification using Power Automate involves organizing documents into categories, which makes managing and locating them easier. With AI Builder's document classification, this can be automated within Power Automate. By training a classification model with example documents, the model will learn to categorize new documents as they are processed within a flow.



Power Automate AI Builder, Process AI Builder, Xpath in Power Automate, AI Builder Data Processing, Xpath Data Extraction, Automate AI Data, AI Builder Xpath Tutorial, Power Automate Data Workflow, Xpath AI Integration, Power Automate Xpath Functions