Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How do I extract a hexBinary attribute value?

How do I extract a hexBinary attribute value?

Scheduled Pinned Locked Moved XML / XSL
questionhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jambolo
    wrote on last edited by
    #1

    I wrote a function that gets a attribute value that is in hex. Am I reinventing the wheel? The problem is that I can't get it to work. Here was my first attempt which failed because it didn't convert to hex (even though the the type is xsd:hexBinary):

    HRESULT		hr;
    CComVariant	value;
    
    hr = pElement->getAttribute( CComBSTR( sName ), &value );
    hr = value.ChangeType( VT\_UINT );
    

    Here is my second attempt which works for values using digits '0'-'9' but fails for values using digits 'a'-'f' (and 'A'-'F') (VarParseNumFromStr returns DISP_E_TYPEMISMATCH):

    HRESULT		hr;
    CComVariant	value;
    NUMPARSE		np	= { 10, NUMPRS\_HEX\_OCT|NUMPRS\_USE\_ALL, 0, 0, 4 };
    unsigned char	digits\[10\];
    CComVariant	vHex;
    
    hr = pElement->getAttribute( CComBSTR( sName ), &value );
    
    hr = VarParseNumFromStr( value.bstrVal, GetUserDefaultLCID(),
    			 NUMPRS\_HEX\_OCT|NUMPRS\_USE\_ALL,
    			 &np, digits );
    np.nBaseShift = 4;
    hr = VarNumFromParseNum( &np, digits, VTBIT\_UI4, &vHex );
    hr = vHex.ChangeType( VT\_UINT );
    

    Anyone know what is wrong or what the right way to do this is?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups