Hi,
Input:
<xhtml><img src="" /></xhmtl><xhtml><img src="" pml="testpml" data-pml="xxads1" /><img src="" pml="xxads2" /></xhmtl><xhtml><img src="" pml="xxads3" /></xhtml><xhtml><img src="" test="" test2="" data-pml="xxads4" pml="4testing" /> test3=""</xhtml><xhtml><img data-pml="xxads5" /> test3=""</xhtml><xhtml><img alt="" src="" pml="xxads6" /> test3=""</xhtml><xhtml><img src="" /><img src="" pml="xxads7" /></xhmtl><xhtml>
Output:
<xhtml><img src="" /></xhmtl><xhtml>testpmlxxads2</xhmtl><xhtml>xxads3</xhtml><xhtml>4testing test3=""</xhtml><xhtml>xxads5 test3=""</xhtml><xhtml>xxads6 test3=""</xhtml><xhtml><img src="" />xxads7</xhmtl><xhtml>
Need to replace the entire img tag with the "pml" or the "data-pml" attibute value or both attributs.
<img src="" pml="xxads1" > need to be replaced with xxads1.
<img pml="xxads1" src="" > need to be replaced with xxads1.
<img data-pml="xxads3" /> need to be replaced with xxads3
<img src="" data-pml="xxads3" /> need to be replaced with xxads3
<img src="" pml="testpml" data-pml="xxads1" /> need to be replaced with testpml
<img src="" test="" test2="" data-pml="xxads4" pml="4testing" /> need to be replaced with 4testing.
If there is no pml or data-pml attribute in img tag, the img tag should be left as it is.
If there are both pml and data-pml attributes in img tag, irrespective of order of occurrence, the img should be replaced with the value in pml attribute.
Need to build a regular expression and use regex.replace to replace values wherever
My apologies. There is a change in our requirement.
Thanks.