How to build a WP_Query using mulitple tags and using AND or OR operator between them

Give something like this a try: (it came from the same page you linked to, just scroll down a bit more).

$args = array(
  'post_type' => 'post',
  'tax_query' => array(
    'relation' => 'AND', // searches for posts meeting both conditions
    array(
      'taxonomy' => 'midgets',
      'field'    => 'slug',
      'terms'    => array( 'tagA,TagB' ), // searches for EITHER tag
    ),
    array(
      'taxonomy' => 'donkeys',
      'field'    => 'slug',
      'terms'    => array( 'tagX,TagY' ), // searches for EITHER tag
    ),
  ),
);
$query = new WP_Query( $args );