How do I add this detail to the XML?

Hi!

I have this structure in the XML at the top:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<Ads> 
       <Ad>
       </Ad>

I need to get this:

<?xml version="1.0" encoding="UTF-8"?>
<Ads formatVersion="3" target="Avito.ru">
       <Ad>
       </Ad>

i.e., I need to

  1. remove: " standalone=“yes”? " and
  2. add " formatVersion=“3” target=“Avito.ru” " in Ads

Please help me. How to do it?

Thank you very much!

Please share the workflow

Information on your n8n setup

  • n8n version: 0.213.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

There is this option:

or add a Code node to your XML node with the following code:

var data = $input.all()[0].json.data

var data = data.replace(' standalone=“yes”? ', '')
var data = data.replace('<Ads>','<Ads formatVersion="3" target="Avito.ru">')

return {"data": data}
2 Likes

HI @dickhoning !

Thank you so much for your time and help! :+1: :handshake:

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