static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary() .set("", "http://www.w3.org/2005/Atom") .set("activity", "http://activitystrea.ms/spec/1.0/") .set("georss", "http://www.georss.org/georss") .set("media", "http://search.yahoo.com/mrss/") .set("thr", "http://purl.org/syndication/thread/1.0");
@Override public String toString() { XmlNamespaceDictionary namespaceDictionary = this.namespaceDictionary; if (namespaceDictionary == null) { namespaceDictionary = new XmlNamespaceDictionary(); } return namespaceDictionary.toStringOf(name, this); }
/** * Shows a debug string representation of an element data object of key/value pairs. * * <p> * It will make up something for the element name and XML namespaces. If those are known, it is * better to use {@link XmlNamespaceDictionary#toStringOf(String, Object)}. * * @param element element data object of key/value pairs ({@link GenericXml}, {@link Map}, or any * object with public fields) */ public static String toStringOf(Object element) { return new XmlNamespaceDictionary().toStringOf(null, element); }
/** * Constructs a new XmlEntity class. */ public XmlEntity() throws XmlPullParserException { super.namespaceDictionary = new XmlNamespaceDictionary(); super.namespaceDictionary.set("s3", "http://s3.amazonaws.com/doc/2006-03-01/"); super.namespaceDictionary.set("", ""); this.xmlPullParser = Xml.createParser(); this.defaultNamespaceDictionary = new XmlNamespaceDictionary(); }
/** * Constructs a new XmlEntity class. */ public XmlEntity() throws XmlPullParserException { super.namespaceDictionary = new XmlNamespaceDictionary(); super.namespaceDictionary.set("s3", "http://s3.amazonaws.com/doc/2006-03-01/"); super.namespaceDictionary.set("", ""); this.xmlPullParser = Xml.createParser(); this.defaultNamespaceDictionary = new XmlNamespaceDictionary(); }
/** * Fills up this ErrorResponse object's fields by reading/parsing values from given Reader input stream. */ @Override public void parseXml(Reader reader) throws IOException, XmlPullParserException { XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); namespaceDictionary.set("", ""); super.parseXml(reader, namespaceDictionary); }
/** * Fills up this ErrorResponse object's fields by reading/parsing values from given Reader input stream. */ @Override public void parseXml(Reader reader) throws IOException, XmlPullParserException { XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); namespaceDictionary.set("", ""); super.parseXml(reader, namespaceDictionary); }
public static void testAtomParse () { FileInputStream fis = null; try { XmlNamespaceDictionary nameSpace = new XmlNamespaceDictionary().set("", "http://www.w3.org/2005/Atom").set("db", "http://www.douban.com/xmlns/").set("gd", "http://schemas.google.com/g/2005").set("openSearch", "http://a9.com/-/spec/opensearchrss/1.0/").set("opensearch", "http://a9.com/-/spec/opensearchrss/1.0/"); XmlObjectParser parser = new XmlObjectParser(nameSpace); //JsonObjectParser parser = new JsonObjectParser(new JacksonFactory()); fis = new FileInputStream("/home/zwei/doubantestxml"); DoubanPeopleEntry result = parser.parseAndClose(fis, Charset.forName("utf-8"), DoubanPeopleEntry.class); System.out.println("result : " + result); } catch (FileNotFoundException ex) { Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex); } finally { try { fis.close(); } catch (IOException ex) { Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex); } } }
parent.child.value = "This is a child"; String xml = new XmlNamespaceDictionary() .toStringOf("Parent", parent.toOrderedXml()); // the important part
static HttpParser parser = new AtomParser(new XmlNamespaceDictionary());
public static final XmlNamespaceDictionary NAMESPACE_DICTIONARY = new XmlNamespaceDictionary();