This XPath statement looks valid to me.
/wsdl:definitions/wsdl:types/xsd:schema/xsd:element[@name='GetBook']//*[@name='ID']/@type
And indeed if I use it in this online parser http://xpather.com/ it works like a champ
I am using libxml2 on alpine linux compiling with gcc
Here is my XPath line :
const char* xpath = "/wsdl:definitions/wsdl:types/xsd:schema/xsd:element[@name='GetBook']//*[@name='ID']/@type";
and here is where I got the demo WSDL from https://tomd.xyz/wsdl/