Hexadecimal to Binary

Python 2, 67 62 60 59 bytes

n=input()
try:print bin(int(n,n[1]<'x'))[2:]
except:print 0

Try it online!

Version that errors on invalid input (27 bytes):

lambda n:bin(int(n,16))[2:]

Try it online!


Pyth, 15 bytes

.B&qr0<z2"0x"vz

Explanation:

             vz  Evaluate the input as a literal, to get a number (casts to integer for hexadecimal input)
      <z2        Select the first two characters of (string) input
    r0           cast to lowercase (0X -> 0x)
   q     "0x"    check whether the text starts with "0x" or "0X" (negative numbers don't) 
  &              If it does, return the casted number
.B               and convert to binary string

Test Suite

With a rules clarification (that 0x must be lowercase) in the OP, you can remove r0 for 13 bytes.

.B&q<z2"0x"vz

05AB1E, 11 bytes

Î2£„0xQi¹Hb

Try it online!

Explanation

Î             # initialize stack with 0 and push input
 2£           # get the first 2 chars of input
   „0xQ       # compare to "0x"
       i      # if equal
        ¹H    # convert input from base-16 to base-10
          b   # convert to binary