How do I add a default namespace with no prefix using XMLSerializer.
I am using org.xmlpull.v1.XmlSerializer on Android.
XmlSerializer xmlSerializer = Xml.newSerializer();
xmlSerializer.startTag("efgh", "abcd");
is giving <n0:abcd xmlns:n0="efgh">
but i want it to be
<abcd xmlns="efgh">
I believe that's what the XmlSerializer.setPrefix(String prefix, String namespace) is for:
http://developer.android.com/reference/org/xmlpull/v1/XmlSerializer.html#setPrefix(java.lang.String, java.lang.String)
Have you tried using that?
It binds the prefix to the namespace. The call is valid for the next element including child elements.
NOTE: this method MUST be called directly before startTag() and if anything but startTag() or setPrefix() is called next there will be exception.
Actually, the namespace without prefix can be seen as an attribute.
so this is code:
xmlSerializer.startTag(null, "abcd");
xmlSerializer.attribute(null, "xmlns", "efgh");
xmlSerializer.endTag(null, "abcd");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With