powered by Jive Software

XML Attributes not interpreted?

It seems although the recieved window of my smack debugger shows attributes, the interpretted window (and thus the api, ignores my attributes) is this the

desired behavior


<x xmlns=’‘jabber:x:testcompany:test’’><my_body value=’‘200’’/>



You need to use a packet provider if you’'d like for Smack to know how to parse your custom XML.



This parseExtension() recreates the original XML, which can then be fed to something else if need be.

public PacketExtension parseExtension( XmlPullParser parser )
            throws Exception {         boolean done = false;         // tagName represents the extension''s root element''s name.
        String tagName = "foo";         // extensionXML accumulates the XML String.
        String extensionXML = parser.getText();         // lastChunk distinguishes <foo/> from <foo></foo>.         String lastChunk = parser.getText();         while ( ! done ) {
            int eventType = parser.next();             // Tags in the form <bar/> cause both a START_TAG
            // and an END_TAG event.  Only one should be dealt
            // with, so perform some crude filtering.
            if ( lastChunk.equals( parser.getText() ) ) {
                if ( parser.getName().equals(_extensionClass) )
                    done = true;                 continue;
            } else {
                lastChunk     = parser.getText();
                extensionXML += parser.getText();
            }             if ( eventType == XmlPullParser.END_TAG &&
                    parser.getName().equals(tagName) )
                done = true;
        }         // Do something with extensionXML to create
        // the PacketExtension.     }