user3901955
user3901955

Reputation: 9

XML Parse error

I am getting below error pls help "parse error:

Error on line 1 of document  : 
The markup in the document preceding the root element must be well-formed. 
Nested exception: The markup in the document preceding the root element must be well-formed.

XML is below

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<'env:Envelope' xmlns>:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"urn:zimbraAdmin\">    
xmlns:ns2=\"urn:zimbraAdmin\"><env:Header><ns2:context/></env:Header><env:Body>    
<ModifyAccountRequest xmlns=\"urn:zimbraAdmin\"><id>4d41ec71-d898-42b8-b522-3c3cdc5583a0</id>
<a n=\"zimbraIsAdminAccount\">TRUE</a>
</ModifyAccountRequest></env:Body></env:Envelope>

Upvotes: 0

Views: 960

Answers (1)

roflplanes
roflplanes

Reputation: 73

That was terribly malformed. Issues are highlighted below:

1. Every instance of \" should be replaced with a simple " as the slash indicates a literal character to Java and is not needed in normal XML.

2. There should be no single quotes around <'env:Envelope' and I honestly have no idea where they came from.

3. The closing carat at xmlns>:env= should be removed, as should the one at the end of the physical line xmlns:ns1=\"urn:zimbraAdmin\">. Removing that carat brings the next namespace statement (which seems unnecessarily identical to ns1) into the envelope tag.

I have no idea what caused the envelope to become so malformed, but you should read up on the purpose of the values and variables you were setting with the xmlns and namespace references so next time you at least uderstand what all the parts of the XML request do. This will help you troubleshoot your own documents in the future.

In the meantime, since you seem to be at a total loss, here is the XML with the errors above corrected.

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:zimbraAdmin" xmlns:ns2="urn:zimbraAdmin">
<env:Header>
    <ns2:context/>
</env:Header>
<env:Body>
    <ModifyAccountRequest xmlns="urn:zimbraAdmin">
        <id>4d41ec71-d898-42b8-b522-3c3cdc5583a0</id>
        <a n="zimbraIsAdminAccount">TRUE</a>
    </ModifyAccountRequest>
</env:Body>
</env:Envelope>

Upvotes: 1

Related Questions