Search in a XML with tag

Hello everyone :slight_smile:

I’m new on n8n, so sorry in advance if my question may seem trivial or a bit silly.

My question is very simple, I have an XML file like this one:

https://catalogue.bnf.fr/api/SRU?version=1.2&operation=searchRetrieve&query=bib.isbn%20adj%20"978-2-01-322343-0"&recordSchema=intermarcXchange

How could I extract for example specifically the field with the tag β€œ015” and the code β€œa”, which would give me β€œ00914463” please ?

Because when I want to transform it into XML to JSON, I lose the separation by tag, I have then all the β€œmxc:datafield” which are added, but I really need by tag.

Thanks in advance to you

Dadourlou

Hi @Dadourlou, welcome to the community :tada:

Any chance you can share your XML file as text rather than a screenshot? This would make it a lot easier for peeps to give it a go :slight_smile:

You can use the option for preformatted text to share code:
image

1 Like

Obviously, sorry for the omission, I edited my message by putting the URL of the file (it is a French public API).

Perfect, thanks a lot!

I have put together an example workflow extracting 00914463 for you:

Example Workflow

In this workflow, I first convert this XML data into JSON data. Then throw away the values I am not interested in using the Set node, splitting out the results via an Item lists node to filter these for the tag in question.

I then split out the subfields for the matching tag and filter for the correct code before formatting the result:

image

Hope this helps! Let me know if you have any questions on this :slight_smile:

1 Like