Reputation: 385
I have a xml below that I'm parsing with JDOM 2.0.5
<?xml version=\"1.0\" encoding=\"UTF-8\"?><order><BGP1>true</BGP1><BGP2>Metro_C&amp;C</BGP2></order>
Now while trying to get the value of the tag using node.getValue() where node is of type Element, it's giving me the node value as
Metro_C&C and not Metro_C&amp;C
Any idea how to resolve this?
Upvotes: 0
Views: 781
Reputation: 328770
The behavior is correct, your expectation is wrong. The text value of the node is Metro_C&C
. When you encode this as XML, the &
character must be replaced with &
since it has a special meaning for XML.
But my feeling is that the input data is already corrupt. The text value should probably be Metro_C&C
which would give the XML encoded value of Metro_C&C
. Patterns like amp;amp;
suggest that someone encoded the data twice.
Upvotes: 2