title: asmack - receiving custom XML messages
body: <p>I'm sending custom XML messages from server to clients. An Android is a client which should know how to handle custom XML messages. The problem with asmack (which I'm using for receiving/sending messages) is that it tries to parse the message itself. An example message of the playerlist is the following:</p>
  
  <pre><code>&lt;html xmlns="http://jabber.org/protocol/xhtml-im"&gt;
  &lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;players xmlns="boxer:players" command="playerlist"&gt;
      &lt;player&gt;test1&lt;/player&gt;
      &lt;player&gt;test2&lt;/player&gt;
    &lt;/players&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In Android, I'm adding a custom Extenstion Provider with:</p>
  
  <pre><code>ProviderManager.getInstance().addExtensionProvider("html","http://jabber.org/protocol/xhtml-im", new XMLPlayerListProvider());
  </code></pre>
  
  <p>And the XMLPlayerListProvider</p>
  
  <pre><code>class XMLPlayerListProvider implements PacketExtensionProvider {
    public XMLPlayerListProvider() {}
  
    public PacketExtension parseExtension(XmlPullParser parser) {
      Log.w("**********HHHHHHHHHHHHH***********", "0");
      boolean stop = false;
      int evtType;
      String n;
      String id = null;
      Log.w("START: "+XmlPullParser.START_TAG, "0");
      while (!stop) {
        try {
         evtType = parser.next();
         n = parser.getName();
         switch (evtType) {
            case XmlPullParser.START_TAG:
               if ("body".equals(n))
                  Log.w("BODY"+n.toString(), "0"); 
               else if ("players".equals(n))
                  Log.w("PLAYERS", "0");
               else if ("player".equals(n))
                  Log.w("PLAYER", "0");
               break;
            case XmlPullParser.END_TAG:
               //Stop parsing when we hit &lt;/item&gt;
               stop = "body".equals(n);
               break;
         }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
  
      return new XMLPlayerList();
    } 
  }
  
  
  
  class XMLPlayerList implements PacketExtension {
  
    public String getElementName() {
      return "aaaaa";
    }
  
    public String getNamespace() {
      return "aaaaa";
    }
  
    public String toXML() {
      return "aaaaa";
    }
  
  }
  </code></pre>
  
  <p>When debugging I'm getting the following output:</p>
  
  <pre><code>W/**********HHHHHHHHHHHHH***********(  654): 0
  W/START: 2(  654): 0
  W/BODYbody(  654): 0
  D/SMACK   (  654): 11:11:58 PM RCV  (1156379984): mand="playerlist"&gt;
  D/SMACK   (  654): &lt;player&gt;test1&lt;/player&gt;
  D/SMACK   (  654): &lt;player&gt;test2&lt;/player&gt;
  D/SMACK   (  654): &lt;/players&gt;
  D/SMACK   (  654): &lt;/body&gt;&lt;/html&gt;&lt;thread&gt;8rOVz0&lt;/thread&gt;&lt;/message&gt;&lt;iq
  W/PLAYERS (  654): 0
  W/PLAYER  (  654): 0
  W/PLAYER  (  654): 0
  W/RESPONSE: &lt;message id="15" to="eee@localhost" from="admin@localhost" type="chat"&gt;&lt;body&gt;
  test1
  test2
  
  &lt;/body&gt;&lt;thread&gt;
  </code></pre>
  
  <p>Here we can see that something strange is going on, but the PacketExtension is indeed getting called. My question now is: how can I change the XMLPlayerListProvider to receive the basic XML message without it being parsed by the default Android packet extension, which I guess is what's outputed as:</p>
  
  <pre><code>test1
  test2
  </code></pre>
  
  <p>That should be:</p>
  
  <pre><code>  &lt;players xmlns="boxer:players" command="playerlist"&gt;
      &lt;player&gt;test1&lt;/player&gt;
      &lt;player&gt;test2&lt;/player&gt;
    &lt;/players&gt;
  </code></pre>