Search code examples
androidxmlsax

android SAXparser get element use attribute value


this is xml
enter image description here

this is SAXhandler
enter image description here

it will get all img. but I just want get phil_1,phil_2 use name="phil".
Can SAXparser do it? And how to do that.


Solution

  • It sounds like you're asking for a SAX filter though honestly that's overkill here. You could easily write something like this instead:

    if (localName.equals("img")) { // do not ignore case
      if ("phil".equals(attributes.getValue("name")) {
        // do your work...