I have a String content that contains (among other text) some XML. I'd like to search inside of this XML for sensitive payment data that should be masked out (eg credit card number).
The string is not a single XML content (that I could parse using JAXB or traverse with dom), but also contains other values like headers, eg:
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: text/xml
Headers: {connection=[Keep-Alive], ...
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
...
<ns2:Payment>
<ns2:CreditCard Number="1234567723" />
What is the best to find the content and replace the numbers using value.replaceAll(".", "X");
?
I mean, how can I best find these values to be replaced inside the xml?