user5458829
user5458829

Reputation: 163

Replacing quotes in xml

I have this below incoming xml where i have " instead of ". How can I replace those with ". please let me know

Input XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <ns1:PDM xmlns:ns1="http://example.com">
   <ns1:ds><Details ID=&quot;3453636&quot; Add=""/></ns1:ds>
  </ns1:PDM>
 </soapenv:Body>
</soapenv:Envelope>

Expected Output:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <ns1:PDM xmlns:ns1="http://example.com">
   <ns1:ds><Details ID="3453636" Add=""/></ns1:ds>
  </ns1:PDM>
 </soapenv:Body>
</soapenv:Envelope>

Upvotes: 0

Views: 46

Answers (1)

Valdi_Bo
Valdi_Bo

Reputation: 30991

Your input text is not a valid XML, so XSLT will refuse to process it.

Instead you can use e.g. the following Perl one-liner script:

perl -pe "s/&quot;/\"/g" -i.bak your_file.xml

Of course, you must have Perl installed.

Replace your_file.xml with the actual name of your file.

This command will replace the input file with the changed content and the original (input) content will be saved as your_file.xml.bak.

Upvotes: 1

Related Questions