I am basically trying to create a stanza similar to this one:
<x xmlns='vcard-temp:x:update'>
<photo/>
</x>
So the question is how to create the "<photo/>" element?
I am trying something like this:
builder.startInnerElement("x", "vcard-temp:x:update");
builder.startInnerElement("photo");
builder.endInnerElement();
builder.endInnerElement();
Which will end up like this:
<x xmlns='vcard-temp:x:update'>
<photo xmlns=""></photo>
</x>
Thanks,
Eilon
On Wed, Jun 13, 2012 at 1:52 AM, Niklas Gustavsson <[email protected]>wrote:
> On Tue, Jun 12, 2012 at 7:01 PM, Eilon Yardeni <[email protected]>
> wrote:
> > I would like to create empty element in a stanza.
> >
> > Using the startInnerElement API always adds a namespace attribute.
>
> It's not perfectly clear what you want to accomplish, so please
> correct me if I understood you wrong. An XML element when namespace
> aware can either be in a namespace or in the empty namespace.
> Namespaces are by default inherited from the element parent. So, if
> you want your inner element to be in the empty namespace, you need:
>
> <outer xmlns="http://example.com"><inner xmlns="" /></outer>
>
> Inner must here override the namespace from it's parent and thus need
> the xmlns="" stuff.
>
> In Vysper:
> new XMLElementBuilder("outer",
> "http://example.com").startInnerElement("inner").endInnerElement()
>
> If you want the inner namespace to have the same namespace as it's parent:
>
> <outer xmlns="http://example.com"><inner /></outer>
>
> In Vysper:
> new XMLElementBuilder("outer",
> "http://example.com").startInnerElement("inner",
> "http://example.com").endInnerElement()
>
> You can also use namespace prefixes as aliases for the full URL, but
> I'm not sure if that makes any difference for your question.
>
> /niklas
>