mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01:00
Improve parseContent() and parseContentDepth()
The idea is that xml-roundtrip should *never* be expected from a XmlPullParser. So what we need is a method that parses the content of an element without relying on getText() returning text if on START_TAG or END_TAG. This is already done by PubSubs ItemProvider. Also add PacketParserUtils.parseElement() which will return the current element as String and use this method in PubSub's ItemProvider.
This commit is contained in:
parent
26b5bc0212
commit
56222d6ee2
8 changed files with 201 additions and 117 deletions
|
|
@ -30,11 +30,11 @@ import java.util.logging.Logger;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.Base32Encoder;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringEncoder;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.provider.DiscoverInfoProvider;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
|
@ -159,8 +159,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
Reader reader = new StringReader(fileContent);
|
||||
XmlPullParser parser;
|
||||
try {
|
||||
parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
parser = PacketParserUtils.newXmppParser();
|
||||
parser.setInput(reader);
|
||||
} catch (XmlPullParserException xppe) {
|
||||
LOGGER.log(Level.SEVERE, "Exception initializing parser", xppe);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue