This project is read-only.

Request to replace special characters &, ", ', > and < in element value

Feb 15, 2011 at 2:09 PM


Please add a feature to replace special characters: &, ", ', > and < with: &amp; &quot; &apos; &gt; and &lt;

For example replace:
<row1>this is & ampersand</row1>
<row2>this is " Straight quotation mark</row2>
<row3>this is ' Apostrophe</row3>
<row4>this is < Left angle bracket</row4> 
<row5>this is > Right angle bracket</row5> 

<row1>this is &amp; ampersand</row1>
<row2>this is &quot; Straight quotation mark</row2>
<row3>this is &apos; Apostrophe</row3>
<row4>this is &lt; Left angle bracket</row4> 
<row5>this is &gt; Right angle bracket</row5> 

Thanks in advanced.


Feb 16, 2011 at 10:29 PM

Hi StickP,

I'm afraid that this feature may not be possible to integrate. Because, xml search replace works on valid xml documents. In your case, the presense of unescaped special characters is causing the xml to become invalid - therefore the xml parser will fail to load the document. This will require a regular expression based search and replace on the content.

I'll try and see if I can come up with a special switch to convert invalid xmls to valid first.

Thanks for using xmlsearchandreplace.