Search code examples
xml

XML Error - Element type must be followed by either attribute specifications, ">" or "/>"


I am relatively new to using XML.

I have a huge XML file and I have tried to create a miniature version of it by hand - I cut pasted from the original file and matched the tags (I think !). I need this miniature version to do some experiments.

I have the above captioned error () that I can't seem to resolve. Looked at other similar questions but couldn't get this to work.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Message xmlns:bs="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns="urn:bcsis" xmlns:head="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">
<stmt>
 <bs:Bal>
        <bs:Tp>
            <bs:CdOrPrtry>
                <bs:Prtry>Outward</bs:Prtry>
            </bs:CdOrPrtry>
        </bs:Tp>
        <bs:AmtCcy="SGD">300</bs:Amt>
        <bs:CdtDbtInd>DBIT</bs:CdtDbtInd>
        <bs:Dt>
            <bs:Dt>2016-10-04</bs:Dt>
        </bs:Dt>
 </bs:Bal>
 <bs:Ntry>
    <bs:AmtCcy="USD">300.00</bs:Amt>
 </bs:Ntry>
</stmt>
<stmt>
<bs:Bal>
        <bs:Tp>
            <bs:CdOrPrtry>
                <bs:Prtry>Inward</bs:Prtry>
            </bs:CdOrPrtry>
        </bs:Tp>
        <bs:AmtCcy="USD">250</bs:Amt>
        <bs:CdtDbtInd>DBIT</bs:CdtDbtInd>
        <bs:Dt>
            <bs:Dt>2016-10-04</bs:Dt>
        </bs:Dt>
</bs:Bal>
<bs:Ntry>
    <bs:AmtCcy="USD">250.00</bs:Amt>
</bs:Ntry>
</stmt>
</Message>

The exact error is:

Element type "bs:AmtCcy" must be followed by either attribute specifications, ">" or "/>".

Appears at the first instance of bs:Amt (where amount is SGD 300).


Solution

  • Your XML is not well-formed due to missing spaces between element and attributes names.

    Change

    <bs:AmtCcy="SGD">300</bs:Amt>
    

    to

    <bs:Amt Ccy="SGD">300</bs:Amt>
    

    likewise for several other similar problems.

    Here is your XML made to be well-formed:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Message xmlns:bs="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"
             xmlns="urn:bcsis" 
             xmlns:head="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">
    <stmt>
      <bs:Bal>
        <bs:Tp>
          <bs:CdOrPrtry>
            <bs:Prtry>Outward</bs:Prtry>
          </bs:CdOrPrtry>
        </bs:Tp>
        <bs:Amt Ccy="SGD">300</bs:Amt>
        <bs:CdtDbtInd>DBIT</bs:CdtDbtInd>
        <bs:Dt>
          <bs:Dt>2016-10-04</bs:Dt>
        </bs:Dt>
      </bs:Bal>
      <bs:Ntry>
        <bs:Amt Ccy="USD">300.00</bs:Amt>
      </bs:Ntry>
    </stmt>
    <stmt>
      <bs:Bal>
        <bs:Tp>
          <bs:CdOrPrtry>
            <bs:Prtry>Inward</bs:Prtry>
          </bs:CdOrPrtry>
        </bs:Tp>
        <bs:Amt Ccy="USD">250</bs:Amt>
        <bs:CdtDbtInd>DBIT</bs:CdtDbtInd>
        <bs:Dt>
          <bs:Dt>2016-10-04</bs:Dt>
        </bs:Dt>
      </bs:Bal>
      <bs:Ntry>
        <bs:Amt Ccy="USD">250.00</bs:Amt>
      </bs:Ntry>
    </stmt>
    </Message>