Reputation: 14278
i have a xml like below:
<expectedJson>
{
"x":"give him $12.25"
}
</expectedJson>
What i am doing is: am comparing the json embeded with the actual json. But after parsing this xml, .
is getting converted to . i.e. period.
I want it to be interpreted as .
not as .
. can anybody help on this?
Upvotes: 0
Views: 205
Reputation: 68975
XML has special characters like &
that have a special meaning in XML. So you cannot use it directly as data. You need to escape it. For Eg. &
should become &
after escaping it. For more details on handling special characters in XML, you can refer to my personal blog post -> Escaping special characters of XML in Java
Upvotes: 0
Reputation: 644
The ampersand needs to be escaped to avoid it being treated as the start of an entity. See this to escape the ampersand.
<expectedJson>
{
"x":"give him $12&#46;25"
}
</expectedJson>
or
<expectedJson>
{
"x":"give him $12&#46;25"
}
</expectedJson>
Upvotes: 1