Android XmlSerializer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android XmlSerializer class.

This code example shows how to use the following methods:attribute, endTag, startTag, text
 
    private void addProblem(String tag, Throwable error) {
        try { 
            recordTestTime(); 
 
            mSerializer.startTag("", tag);
            mSerializer.attribute("", ATTRIBUTE_MESSAGE, safeMessage(error));
            mSerializer.attribute("", ATTRIBUTE_TYPE, error.getClass().getName());
            StringWriter w = new StringWriter();
            error.printStackTrace(mFilterTraces ? new FilteringWriter(w) : new PrintWriter(w));
            mSerializer.text(w.toString());
            mSerializer.endTag("", tag);
        } catch (IOException e) {
            Log.e(LOG_TAG, safeMessage(e));
        } 
    } 
 
    private void recordTestTime() throws IOException { 
        if (!mTimeAlreadyWritten) {
            mTimeAlreadyWritten = true;

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:endDocument, endTag, flush
        return super.onException(obj, thr);
    } 
 
    void endTestSuites() { 
        try { 
            mTestSuiteSerializer.endTag(null, "testsuites");
            mTestSuiteSerializer.endDocument();
            mTestSuiteSerializer.flush();
 
            mWriter.flush();
            mWriter.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:attribute, endTag, startTag
    } 
 
    private static void serializeFeedUrl(XmlSerializer serializer,
            FeedUrl feedUrl)
            throws IOException { 
        serializer.startTag(NAMESPACE_GSYNC_URI, "feedurl");
        serializer.attribute(null /* ns */, "value", feedUrl.getFeed());
        serializer.attribute(null /* ns */, "service", feedUrl.getService());
        serializer.attribute(null /* ns */, "authtoken", feedUrl.getAuthToken());
        serializer.endTag(NAMESPACE_GSYNC_URI, "feedurl");
    } 
 
    private static void serializeClientToken(XmlSerializer serializer,
            String clientToken)
            throws IOException { 
        if (StringUtils.isEmpty(clientToken)) {
            clientToken = "";
        } 
        serializer.startTag(NAMESPACE_GSYNC_URI, "clientToken");
        serializer.text(clientToken);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:flush, setFeature, setOutput
 
    private String nodeToNormalizedString(Node node)
            throws XmlPullParserException, IOException { 
        StringWriter writer = new StringWriter();
        XmlSerializer xmlSerializer = xmlPullParserFactory.newSerializer();
        xmlSerializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        xmlSerializer.setOutput(writer);
        emitNode(xmlSerializer, node);
        xmlSerializer.flush();
        return writer.toString();
    } 
 
    private void emitNode(XmlSerializer serializer, Node node) throws IOException {
        if (node == null) {
            throw new UnsupportedOperationException("Cannot emit null nodes");
 
        } else if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            serializer.startTag(element.getNamespaceURI(), element.getLocalName());
            emitAttributes(serializer, element);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:attribute
    } 
 
    private static class MySerializer implements XmlSerializerAndParser<AuthenticatorDescription> {
        public void writeAsXml(AuthenticatorDescription item, XmlSerializer out)
                throws IOException { 
            out.attribute(null, "type", item.type);
        } 
 
        public AuthenticatorDescription createFromXml(XmlPullParser parser)
                throws IOException, XmlPullParserException { 
            return AuthenticatorDescription.newKey(parser.getAttributeValue(null, "type"));
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:attribute, endTag, startTag
	private static final String XMLATTR_relId = "relId"; //$NON-NLS-1$
	private static final String XMLATTR_warnaLatar = "warnaLatar"; //$NON-NLS-1$
	 
	public void writeXml(XmlSerializer xml, int relId) throws IOException {
		// urutan ga/belum dibekap 
		xml.startTag(null, XMLTAG_Label);
		xml.attribute(null, XMLATTR_relId, String.valueOf(relId));
		xml.attribute(null, XMLATTR_judul, title);
		if (backgroundColor != null) xml.attribute(null, XMLATTR_warnaLatar, backgroundColor);
		xml.endTag(null, XMLTAG_Label);
	} 
 
	public static Label dariAttributes(Attributes attributes) {
		String judul = attributes.getValue("", XMLATTR_judul); //$NON-NLS-1$
		String warnaLatar = attributes.getValue("", XMLATTR_warnaLatar); //$NON-NLS-1$
		 
		return new Label(-1, judul, 0, warnaLatar);
	} 
	 
	public static int getRelId(Attributes attributes) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:attribute, endTag, ignorableWhitespace, startTag
        } 
 
		// check for using attrib as node or item 
		String tagName = item ? "item" : type;
 
		serializer.startTag(null, tagName);
		if (item) {
			serializer.attribute(null, "type", type);
		} 
		serializer.attribute(null, "name", res.getResSpec().getName());
 
		serializeExtraXmlAttrs(serializer, res);
 
		if (!body.isEmpty()) {
			serializer.ignorableWhitespace(body);
		} 
 
		serializer.endTag(null, tagName);
	} 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:attribute, endTag, startTag
 */ 
public class ResIdValue extends ResValue implements ResValuesXmlSerializable { 
	@Override 
	public void serializeToResValuesXml(XmlSerializer serializer,
			ResResource res) throws IOException, AndrolibException {
		serializer.startTag(null, "item");
		serializer
				.attribute(null, "type", res.getResSpec().getType().getName());
		serializer.attribute(null, "name", res.getResSpec().getName());
		serializer.endTag(null, "item");
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:endTag, startTag
        mPref = new PreferredComponent(this, parser);
    } 
 
    public void writeToXml(XmlSerializer serializer) throws IOException {
        mPref.writeToXml(serializer);
        serializer.startTag(null, "filter");
        super.writeToXml(serializer);
        serializer.endTag(null, "filter");
    } 
 
    public boolean onReadTag(String tagName, XmlPullParser parser) throws XmlPullParserException,
            IOException { 
        if (tagName.equals("filter")) {
            if (DEBUG_FILTERS) {
                Log.i(TAG, "Starting to parse filter...");
            } 
            readFromXml(parser);
            if (DEBUG_FILTERS) {
                Log.i(TAG, "Finished filter: depth=" + parser.getDepth() + " tag="
                        + parser.getName());
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:endTag, startTag, text
        if (value == null) {
            return; 
        } 
 
        if (namespace == null) {
            writer.startTag(null, tag);
        } else { 
            writer.startTag(namespace, tag);
        } 
        writer.text(value);
        writer.endTag(namespace, tag);
    } 
 
    /** 
     * Writes an Integer tag. 
     *  
     * @throws IOException 
     * @throws IllegalStateException 
     * @throws IllegalArgumentException 
     */ 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android XmlSerializer Questions & Answers:

See Code Examples for Android XmlSerializer Methods: