We are using a flow that utilizes the Loop Type: XML
We provide values for XML File, an XPath Main Query and Xpath Query1 values. When the deployment runs it is resulting in 0 iterations of the flow being executed.
If we download the Execution Information Logs we can see that it results in null XPATH results. See below:
=================================================================================================
2022-11-11 21:54:15,901 - Starting Flow "Loop_Over_XML_Flow(P2854.F379674.E379676)"
=================================================================================================
2022-11-11 21:54:15,929 - Starting Iteration of "Loop_Over_XML_Flow(P2854.F379674.E379676)"
Input fields:
XML Content/ File Path = /tmp/XML_Deployment_manifest.xml
Xpath Main Query = /DeploymentManifest/Deployment/step[@name='TestXML1']/XML_Loop/Server/Test/ReleaseStr1
Default Empty Query Result =
Xpath Query 1 = @templateProperty
Xpath Query 2 = null
Xpath Query 3 = null
Xpath Query 4 = null
Xpath Query 5 = null
Xpath Query 6 = null
Xpath Query 7 = null
Xpath Query 8 = null
Xpath Query 9 = null
Xpath Query 10 = null
Fail If Element Is Not Full = false
Ignore Namespaces = true
Output fields:
Iteration Element = null
Number Of Elements = 0
Has Empty Result = null
Xpath Result 1 = null
Xpath Result 2 = null
Xpath Result 3 = null
Xpath Result 4 = null
Xpath Result 5 = null
Xpath Result 6 = null
Xpath Result 7 = null
Xpath Result 8 = null
Xpath Result 9 = null
Xpath Result 10 = null
Iter Counter = 1
Iteration description: Xml loop finished after 0 iterations.
Release : Nolio 6.7
The XPath query is not able to find a successful match in the file provided. It does not matter what your XML file is or what your XPATH query is. If you're using an XML loop and it is resulting in 0 iterations then it is recommended to use an online/offline XPath testing tool where you can test the XPath against the content in the file. See the "Additional Information" section below for additional details.
Fix the query and/or data.
Keep in mind that the query might not always be wrong. It might be the XML file/data. It all depends on what your application team expects to be used, identifying/using standards (may apply if you're using a shared component), etc..
See below for tips on troubleshooting.
If you have access to a Linux machine, it might have xmllint available on it. This can be used to test your XML/XPath. Here is an example:
Let's suppose we are pointing the Flow (that loops over XML) to a file that has the following XML data:
<?xml version="1.0" encoding="UTF-8"?>
<DeploymentManifest name="XML_Deployment" project="NewProject" build="1.0">
<properties></properties>
<Initialization></Initialization>
<Deployment>
<step name="TestXML">
<XML_Loop>
<Server>
<Test>
<ReleaseStr1 templateProperty="false"></ReleaseStr1>
<ReleaseStr2 templateProperty="false"></ReleaseStr2>
</Test>
</Server>
</XML_Loop>
</step>
</Deployment>
<Post-Deployment></Post-Deployment>
</DeploymentManifest>
This XML data is in a folder/file: /tmp/XML_Deployment_manifest.xml
I can test the XPath Query above by running:
[user@host tmp]$ xmllint --xpath "//DeploymentManifest/Deployment/step[@name='TestXML1']/XML_Loop/Server/Test/ReleaseStr1" XML_Deployment_manifest.xml
XPath set is empty
We can see that it returns "XPath set is empty". To troubleshoot, try taking off the query piece by piece. For example, try:
All of the tests, until the last one, returned "XPath set is empty". If we analyze the last test and the XML file then we'll find that the problem is the @name='TestXML1' attribute that it's searching for. It doesn't exist. If we change the query to be:
xmllint --xpath "//DeploymentManifest/Deployment/step[@name='TestXML']/XML_Loop/Server/Test/ReleaseStr1" XML_Deployment_manifest.xml
Then it will return:
<ReleaseStr1 templateProperty="false"/>
Keep in mind that the query might not always be wrong. It might be the XML file/data. It all depends on what your application team expects to be used, identifying/using standards (may apply if you're using a shared component), etc..