0

I have an XML file as shown below:

<headerRule name='modifyCType'
            headerName='Content-Type'
            action='manipulate'
            matchValue='($checkPT18.$chkPT18)&!$checkAnnexb.$chkAnnexb)'
            newValue='<'
            methods='INVITE'>
</headerRule>

While unmarshalling using JAXB, it says invalid character & on matchValue='($checkPT18.$chkPT18)&!$checkAnnexb.$chkAnnexb)' which I replaced with &amp and it is working now i.e. matchValue='($checkPT18.$chkPT18)&amp;!$checkAnnexb.$chkAnnexb)'.

However, there is another invalid character < on newValue='<' when I replace it with &lt it works fine however it replaces all '<' character with &lt including &ltheaderRule as shown below:

&lt;headerRule name='modifyCType'
            headerName='Content-Type'
            action='manipulate'
            matchValue='($checkPT18.$chkPT18)&amp;!$checkAnnexb.$chkAnnexb)'
            newValue='&lt;'
            methods='INVITE'>
&lt;/headerRule>

which I do not want. I want:

<headerRule name='modifyCType'
            headerName='Content-Type'
            action='manipulate'
            matchValue='($checkPT18.$chkPT18)&amp;!$checkAnnexb.$chkAnnexb)'
            newValue='&lt;'
            methods='INVITE'>
</headerRule>

How to replace < with &lt only for attribute value i.e. newValue using jaxb parsing?

Nitin
  • 53
  • 7

0 Answers0