If requested XPath is not in file

In a dir are a number of xml files. With Generic XML reader I try to retrieve data from these files with XPath query “//transfer/skippedwells/w” .
image
And this works fine.
But now the problem. Sometimes there are no “skippedwells” in a file and then we get an error message.

What I like to do is to check the content of the xml files and check if there is the path “//transfer/skippedwells/w” if so then continue with the file and if not then don’t process this file.

Does anyone know a solution to check the content of xml files before processing them

Thanks

Hi @RonG,
can you read in the whole file and then use the XPath node to extract the info you need? It should then not throw an error but instead return a missing cell, which you can easily handle, e.g. by filtering rows with missing values using the Missing Value node.
Kind regards
Alexander

Hi Alexander,

this is the workflow:
image
and I get the error “ERROR Generic XML Reader 0:23 Configure failed (RuntimeException): java.lang.IndexOutOfBoundsException: Index: 0” if there is an xml file without the “skippedwells\w”

Thanks,

Ron

Hi,
can you read in the file without XPath and then use the XPath node to extract the data you are interested in? The node will not fail, but returns a missing value instead.
Kind regards
Alexander

2 Likes

Hi Alexander,

this does the trick,

thanks,

Ron

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.