macedigital / express-xml-bodyparser

Simple XML body parser connect/express middleware
MIT License
69 stars 27 forks source link

Create a option to ignore (or convert) character & #30

Open helderam opened 1 year ago

helderam commented 1 year ago

Hello,

I have an XML file with a "&" character inside a field, and I am receiving an error message: "Error: Invalid character in entity name". However, when I manually remove the "&", the error is resolved.

Is it possible to create an option that can ignore or remove this "&" character automatically?

Thank you.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:boor="http://www.accurate.com/acec/AcecBOSOAIntegration/BOOrderIntegration">
  <soapenv:Header />
  <soapenv:Body>
    <boor:integrateOrderRequest>
      <order xmlns:ns2="http://www.accurate.com/acec/InvoiceInfo"
        xmlns="http://www.accurate.com/acec/order">
        <orderId>52379860</orderId>
        <totalAmount>203.90</totalAmount>
        <deliveryAddress>
          <addressId>53933</addressId>
          <recipientNm>BRUNO & MENDES TREINAMENTO E SERVICOS LTDA</recipientNm>
          <address>AV RAIMUNDO PEREIRA DE MAGALHAES</address>
        </deliveryAddress>
      </order>
    </boor:integrateOrderRequest>
  </soapenv:Body>
</soapenv:Envelope>

I am getting ERROR:

Error: Invalid character in entity name Line: 20 Column: 30 Char:
at error (/home/integrador/node_modules/sax/lib/sax.js:651:10) at strictFail (/home/integrador/node_modules/sax/lib/sax.js:677:7) at SAXParser.write (/home/integrador/node_modules/sax/lib/sax.js:1491:13) at Object.module.exports [as xml2js] (/home/integrador/node_modules/xml-js/lib/xml2js.js:346:12) { note: [Circular *1]