Embed hex character in xml
I have a set of single hecidecimal values represented as string in format "92", "BD", for example, and I need to include them in an xml document.
I don't really care about the hexidecimal format I'm actually interested in the content that the hex value represents. What is the most appropriate approach to get that into xml. I suppose I could decode to char then just put the char value in xml, as long as the char is valid within xml.
How do I decode the hex string
Actually you don't have hexadecimal values represented as strings. You have binary values (octets) represented as hexadecimal strings. It's important to make these distinctions or you can get very muddled.
How to represent binary values (octets) in XML? XSD supports two representations, xs:hexBinary
and xs:base64Binary
. Base64 is popular and converters are widely available. But you can choose your own format if you prefer.