@Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    // Logger.d(TAG, "_   start Element " + uri + ", " + localName + ", " + qName);

    isValid = true;
    isThumbnail = false;
    passCharacters = false;
    String name = localName;

    switch (mapToField(name)) {
      case CONTAINER:
        mContent = new Item();
        mContent.setId(attributes.getValue(ATTRIBUTE_ID));
        mContent.setParentid(attributes.getValue(ATTRIBUTE_PARENT_ID));
        mContent.setChildCount(attributes.getValue(ATTRIBUTE_CHILD_COUNT));
        break;

      case ITEM:
        mContent = new Item();
        mContent.setId(attributes.getValue(ATTRIBUTE_ID));
        mContent.setParentid(attributes.getValue(ATTRIBUTE_PARENT_ID));
        mMaxPixels = 0x7FFFFFFF;

        ImageItemProcessing = false;
        resolution_set = null;
        resolution_set = resolution_set_init;
        break;

      case RES:
        {
          ImageItemProcessing = true;
          String protocolInfo = attributes.getValue(ATTRIBUTE_PROTOCOL_INFO);
          String resolution = null;

          if (null != protocolInfo) {
            String protocolInfoToken[] = protocolInfo.split(":");
            short iva = detectMediaType(protocolInfoToken[2]);

            switch (iva) {
              case IMAGE:
                res_index = UNDEFINE;

                if (true == protocolInfoToken[2].endsWith("x-ycbcr-yuv420")) {
                  isValid = false;
                  passCharacters = true;
                } else {
                  res_index = findTAGIndex(protocolInfoToken[3]);

                  resolution = attributes.getValue(ATTRIBUTE_RESOLUTION);
                  if ((UNDEFINE != res_index) && null != resolution) {
                    resolution_set[res_index][RES_VALUES] = resolution;
                    int difference = 0;
                    int pixels = 0;
                    String[] hw = resolution.split("x");

                    pixels = Integer.parseInt(hw[0]) * Integer.parseInt(hw[1]);
                    difference = Math.abs(REFERENCED_HD_RESOLUTION - pixels);

                    if (mMaxPixels > difference) {
                      mMaxPixels = difference;
                    } else {
                      isValid = false;
                      passCharacters = true;
                    }

                    hw = null;
                  } else if (null != mContent.getUrl()) {
                    isValid = false;
                    passCharacters = true;
                  }
                }
                break;

              case VIDEO:
                if (null == mContent.getUrl()) {
                  /*if ( true == protocolInfoToken[0].equals( "rtsp-rtp-udp" )) {
                      isValid = false;
                      passCharacters = true;
                  }
                  else if ( true == protocolInfoToken[3].contains( "DLNA.ORG_CI=1" )) {
                      isValid = false;
                      passCharacters= true;
                  }
                  else if ( true == protocolInfoToken[2].endsWith( "x-ms-wmv" )) {
                      if ( false == protocolInfoToken[3].contains( "DLNA.ORG_PN=WMVSPML_BASE" ) &&
                           false == protocolInfoToken[3].contains( "DLNA.ORG_PN=WMVSPLL_BASE" )) {
                          isValid = false;
                          passCharacters = true;
                      }
                  }*/
                  if (false == protocolInfoToken[0].equals("rtsp-rtp-udp")
                      && false == protocolInfoToken[3].contains("DLNA.ORG_CI=1")) {
                    resolution = attributes.getValue(ATTRIBUTE_RESOLUTION);
                  } else {
                    isValid = false;
                    passCharacters = true;
                  }
                }
                break;

              case AUDIO:
                if (true == protocolInfoToken[3].contains("DLNA.ORG_CI=1")) {
                  isValid = false;
                  passCharacters = true;
                }
                break;

              default:
                isValid = false;
                passCharacters = true;
                break;
            }

            // if ( true == isValid && false == isThumbnail ) {
            if (true == isValid) {

              String size = attributes.getValue(ATTRIBUTE_SIZE);

              if (IMAGE == iva || VIDEO == iva) {
                if (null == resolution) {
                  resolution = "";
                }
                mContent.setResolution(resolution);
                resolution = null;
              }

              if (AUDIO == iva || VIDEO == iva) {
                mContent.setDuration(
                    UpnpTool.getTimeSecond(attributes.getValue(ATTRIBUTE_DURATION)));
              }

              if (null == size) {
                size = "0";
              }

              mContent.setFileSize(size);
              mContent.setFormat(protocolInfoToken[2]);
              mContent.setProtocolInfo(protocolInfo);
              mContent.setProtocolName(protocolInfoToken[0]);

              size = null;
            }

            protocolInfo = null;
            protocolInfoToken = null;
          }
        }
        break;

      case UPNP_ALBUM_ART_URI:
        profileId = attributes.getValue(ATTRIBUTE_PROFILE_ID);

        if (false == profileId.equals("JPEG_TN")) {
          isValid = false;
          passCharacters = true;
        }

        break;

      case UPNP_ARTIST:
        role = attributes.getValue(ATTRIBUTE_ROLE);
        if (role != null) {
          if (false == role.equals("AlbumArtist")) {
            isValid = false;
            passCharacters = true;
          }
        } else {
          isValid = false;
          passCharacters = true;
        }
        break;

      case DC_CREATOR:
      case DC_DATE:
      case DC_TITLE:
      case UPNP_ACTOR:
      case UPNP_ALBUM:
      case UPNP_CLASS:
      case UPNP_GENRE:
      case UPNP_ORIGINAL_TRACK_NUMBER:
        break;

      default:
        isValid = false;
        passCharacters = true;
        Logger.d(TAG, "   skip Element");
        break;
    }
  }
 @Override
 public void endDocument() throws SAXException {
   super.endDocument();
   Logger.w(TAG, "endDocument()");
   // Do Nothing;
 }
  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    super.endElement(uri, localName, qName);
    String name = localName;

    // Logger.d(TAG, "    end Element " + uri + "," + localName + "," + qName);

    switch (mapToField(name)) {
      case CONTAINER:
        mContentList.add(mContent);
        break;

      case DC_CREATOR:
        mContent.setCreator(currentText.toString());
        break;

      case DC_DATE:
        mContent.setDate(currentText.toString());
        break;

      case DC_TITLE:
        mContent.setTitle(currentText.toString());
        break;

      case ITEM:
        if (ImageItemProcessing) {
          // Desc search from TN to LRG
          for (int i = 0; i < resolution_set.length; i++) {
            String URL = resolution_set[i][IMG_URL];
            if (null != URL) {
              // Logger.d(TAG, " set thumbnail:" +
              // resolution_set[i][RES_TAG]);
              mContent.setThumbnailUrl(URL);
              break;
            }
          }

          // ASC search from LRG to TN
          for (int i = resolution_set.length - 1; i >= 0; i--) {
            String URL = resolution_set[i][IMG_URL];
            if (null != URL) {
              // Logger.d(TAG, " set url:" +
              // resolution_set[i][RES_TAG]);
              mContent.setUrl(URL);
              mContent.setResolution(resolution_set[i][RES_VALUES]);
              break;
            }
          }
        }
        ImageItemProcessing = false;
        mContentList.add(mContent);
        break;

      case RES:
        if (res_index != UNDEFINE) {
          resolution_set[res_index][IMG_URL] = currentText.toString();
          // Logger.d(TAG, " res_index " + res_index);
        }
        break;

      case UPNP_ACTOR:
        mContent.setActor(currentText.toString());
        break;

      case UPNP_ALBUM:
        mContent.setAlbum(currentText.toString());
        break;

      case UPNP_ALBUM_ART_URI:
        mContent.setAlbumUrl(currentText.toString());
        profileId = null;
        break;

      case UPNP_ARTIST:
        if (true == isValid && null != role) {
          if (true == role.equals("AlbumArtist")) {
            mContent.setArtist(currentText.toString());
          }
          role = null;
        }

        break;

      case UPNP_CLASS:
        mContent.setUpnpClass(currentText.toString());
        break;

      case UPNP_GENRE:
        mContent.setGenre(currentText.toString());
        break;

      default:
        Logger.d(TAG, "   SKIP !!");
        // Do Nothing;
        break;
    }

    currentText.setLength(0);
  }
 @Override
 public void startDocument() throws SAXException {
   super.startDocument();
   mContentList = new ArrayList<Item>();
   Logger.w(TAG, "startDocument()");
 }