Hi, i have to create xml something like:
<xml version="1.0" encoding="UTF-8"?>
<tns:Message>
<tns:Header>
<tns:to>CCM</tns:to>
<tns:from>CPM</tns:from>
<tns:type>New</tns:type>
</tns:Header>
</tns:Message>
from my java object.
I am trying to do something like this
DocumentBuilderFactory factory
= DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
Document doc = impl.createDocument(null,"tns:Message", null);
but in the last line it gives me error
"NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces."
but if i pass "Message" instead of "tns:Message" it works fine. Since tns is the namespace prefix am i need to use it , how can i make it possible.
Any suggestions?