Can't convert json to xml (Invalid character in name)

Describe the problem/error/question

When I try to convert the json below to xml, I get the error “Invalid character in name” with a stack trace.

I’ve found the same error on other threads in the community, but my json blob doesn’t seem to have any of the problems they discussed.

json is below

What is the error message (if any)?

Stack trace

Error: Invalid character in name at XMLStringifier.module.exports.XMLStringifier.assertLegalName (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js:213:15) at XMLStringifier.assertLegalName (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js:4:59) at XMLStringifier.module.exports.XMLStringifier.name (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js:29:19) at new XMLElement (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLElement.js:26:34) at XMLElement.module.exports.XMLNode.node (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLNode.js:304:15) at XMLElement.module.exports.XMLNode.element (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLNode.js:236:28) at XMLElement.module.exports.XMLNode.ele (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/node_modules/xmlbuilder/lib/XMLNode.js:531:19) at /root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/lib/builder.js:108:37 at Builder.exports.Builder.Builder.buildObject (/root/.npm/_npx/a8a7eec953f1f314/node_modules/xml2js/lib/builder.js:120:14) at ExecuteContext.execute (/root/.npm/_npx/a8a7eec953f1f314/node_modules/n8n-nodes-base/nodes/Xml/Xml.node.ts:271:36)

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

[
  {
    "HOSTNAME": "AC 800M PM851",
    "description": "AC 800M PM851",
    "ip_address": [
      "192.168.113.202"
    ],
    "MAC_ADDRESS": [
      "00:00:23:18:28:42"
    ],
    "OS Name": "Firmware: 5.1.100.13",
    "vendor": "ABB",
    "portNumber": [
      "cotp",
      "mms"
    ],
    "complianceScanDate": 1744218091408,
    "supplier": "Nozomi",
    "sourceType": "REMOTE",
    "dataSource": "VA_SCAN",
    "asset_id": "01f23941-b6f6-4ef9-bdb7-ba7ae545162e",
    "vendorVulnID": "CVE-2019-12262",
    "vendorVulnName": "Improper Access Control",
    "cvssBaseScore": 9.8,
    "cvssSource": "VENDOR",
    "vendorName": "Nozomi Vantage",
    "comment": "Wind River VxWorks 6.6, 6.7, 6.8, 6.9 and 7 has Incorrect Access Control in the RARP client component. IPNET security vulnerability: Handling of unsolicited Reverse ARP replies (Logical Flaw).",
    "remediation": [
      {
        "url": "https://www.se.com/ww/en/download/document/SESB-2019-214-01/",
        "name": "Schneider Electric advisory",
        "source": "NNLABS",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://rockwellautomation.custhelp.com/app/answers/answer_view/a_id/1088561",
        "name": "Rockwell Automation advisory",
        "source": "NNLABS",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://new.abb.com/news/detail/28733/cyber-security-notification",
        "name": "ABB advisory",
        "source": "NNLABS",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://support.f5.com/csp/article/K41190253",
        "name": "https://support.f5.com/csp/article/K41190253",
        "source": "CONFIRM",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://support2.windriver.com/index.php?page=cve&on=view&id=CVE-2019-12262",
        "name": "https://support2.windriver.com/index.php?page=cve&on=view&id=CVE-2019-12262",
        "source": "CONFIRM",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://www.belden.com/dfsmedia/f1e38517e0cd4caa8b1acb6619890f5e/7960-source/options/view/security-bulletin-ip-hios-garrettcom-dx-bsecv-2019-05",
        "name": "https://www.belden.com/dfsmedia/f1e38517e0cd4caa8b1acb6619890f5e/7960-source/options/view/security-bulletin-ip-hios-garrettcom-dx-bsecv-2019-05",
        "source": "CONFIRM",
        "reference_type": "Vendor Advisory"
      },
      {
        "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-189842.pdf",
        "name": "https://cert-portal.siemens.com/productcert/pdf/ssa-189842.pdf",
        "source": "[email protected]",
        "reference_type": "Third Party Advisory"
      },
      {
        "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-352504.pdf",
        "name": "https://cert-portal.siemens.com/productcert/pdf/ssa-352504.pdf",
        "source": "[email protected]",
        "reference_type": "Third Party Advisory"
      },
      {
        "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-617233.pdf",
        "name": "Advisory SSA-617233",
        "source": "CONFIRM",
        "reference_type": "Vendor Advisory"
      }
    ]
  }
]

Information on your n8n setup

  • n8n version: 1.92.2 (Self Hosted)
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npx n8n
  • Operating system: FreeBSD

Hey @gbCoE

I was able to reproduce the error you mentioned and found the root cause,
The issue is that one of the JSON properties contains a space in its key name:

"OS Name"

To fix it, try renaming the key to something like:

"OS_Name"


If this solves your problem, kindly mark the reply as the solution :white_check_mark::pray:t2:

2 Likes

Thank you! I even looked for spaces in the keys, and somehow missed that entirely.

I changed it to OS_Name and it’s working fine now.

2 Likes

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