Im in the process of creating XML as a Node for a RMI program I am developing but I have run across a problem. I can create the XML using DOM but I am struggling to add namespace and version to the top of my XML. I have tried using setAttribute and setAttributeNS but at the moment lost in what else I can do.
The java code to create the element is:
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Node root = doc.createElement("Request"); doc.appendChild(root); //code ommited
The result I get currently is:
<Request> <Identification> <UserID>user</UserID> <Password>pass</Password> </Identification> </Request>
In the request section I need it to look like:
<Request xsi:noNamespaceSchemaLocation="URL" Version="1.0">
Any help will be appreciated to help solve this issue!