Service Virtualization

  • 1.  how to print < and > in test case

    Posted May 24, 2018 05:40 PM

    My test case has to print &lt; and &gt; But these values are converting into <  and >.

     

    String str = "&lt;![CDATA[{\"request\":{\"start\":\"2017-01-01T00:00:00.000-08:00\"}} ]]&gt;";

     

    Here is my string object. When i'm trying to return it below string object value is printing.

     

    <![CDATA[{"request":{"start":"2017-01-01T00:00:00.000-08:00"}} ]]>

     

    Please help me on this>



  • 2.  Re: how to print < and > in test case
    Best Answer

    Broadcom Employee
    Posted May 25, 2018 02:46 PM

    Try replacing "&" with "&amp;"

    "&amp;" will get printed out as "&" and the "lt" and "gt" will be unmodified

     

    String str = "&amp;lt;![CDATA[{\"request\":{\"start\":\"2017-01-01T00:00:00.000-08:00\"}} ]]&amp;gt;";

     

    Hope this helps.



  • 3.  Re: how to print < and > in test case

    Posted May 25, 2018 03:40 PM

    Thank you so much. It worked