I am supposed to insert a piece of xml string withing an xml doc. I have created an xml string using DOM. A Web service will accept this string as an input and create the master xml. My child xml looks ok but after passing to the web service it looks
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
<?xml version="1.0" encoding="UTF-8" standalone="
no"?><orders><order cancel="0" orderKey="
To append a child element, you can use the appendChild() method in org.w3c.dom.Node class.
So when you get a child node like a String, you parse it to a DOM document and append the created child node with the existing parent node you already have.
I am not sure though why your input String is appended with the SOAP wsdl (I guess).
Joined: Jul 16, 2012
Thanks for your prompt reply. But the issue i m facing is my work is to generate the child string and send it to an API. API will automatically incorporate the child xml. Issue is that i send in XML format.. for eg "<a>hello</a>". But the API converts it into "< hello >". and as a result parser flags an error
Joined: May 31, 2011
Mrinal Bhattacharjee wrote:But the API converts it into "< hello >". and as a result parser flags an error
Please be more specific. Can you please post the code you use to generate the XML string?