I recommend libxml2 and xmlsec which are ideal for this purpose.
The API may seem difficult to read at first, but it works well. xmlsec uses OpenSSL to achieve the cryptographic part.
Providing a βshortβ example here is probably difficult because the three libraries require some initialization and many C calls.
ereOn source share