Hi all,

I'm using XML bean to read an XML string, and modify the namespace before
saving it back as XML string.

Say the xml that I have is:

<ZFI>
    ...
</ZFI>

and I already have an XML object that represent this xml. What I had to do
is:

        XmlCursor cursor = xmlObject.newCursor();
        // Cursor at STARTDOC
        cursor.toNextToken();
        // Cursor at START
        cursor.toNextToken();
        // Cursor after START
        cursor.insertAttribute("xmlns","http://www.namespace.com";);

I tried to do (at the same line as cursor.insertAttribute) :

        cursor.insertNamespace("","http://www.namespace.com";);

but it didnt work. i.e the XML string produced doesnt have the namespace. So
instead of having:

<ZFI xmlns="http://www.namespace.com";>...

it only has:

<ZFI>...

Is there any reason why this happened? What is the best way to insert the
default namespace, if I only have access
to the XMLObject (i.e. apart from specifying the namespace during the
construction of XMLObject) ?


Thanks in advance for the helps!


-- 
Best regards,


WiB
-------------------
http://alexwibowo.blogspot.com

Reply via email to