cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XML document structures must start and end within the same entity

Bhargavakrishna
Active Contributor
0 Likes
17,823

Hi Experts,

We are on SAP PO 7.5.

When we are executing the java mapping in ESR, it is throwing the below error..

Error Details:

Unable to display tree view; Error when parsing an XML document (XML document structures must start and end within the same entity.)

I have verified the output payload and could see the end tag "</ns0:MT_BD_QP_ECC>"is missing after last </row> tag.

It should not repeat after every </row> tag.

Expected output

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_BD_QP_ECC xmlns:ns0="urn:BDG-is.com/xi/KWE/KIG/01_db">
<row>
<pSystemId>DUK</pSystemId>
<pRecordType>BD</pRecordType>
<pSourceSystem>SAPXI</pSourceSystem>
<pStatus>1</pStatus>
<pPlantCodeCHO</pPlantCode>
<pBlockCode>B</pBlockCode>
<pDateTimeFrom>2019-01-01T00:00:00.000+00:00</pDateTimeFrom>
<pDateTimeTo>2019-01-31T23:59:59.999+00:00</pDateTimeTo>
<pMaterial>Apple</pMaterial>
<pAmount>106789.055</pAmount>
<pAmountUnit>HW</pAmountUnit>
</row>
<row>
<pSystemId>DUK</pSystemId>
<pRecordType>BD</pRecordType>
<pSourceSystem>SAPXI</pSourceSystem>
<pStatus>1</pStatus>
<pPlantCode>CHO</pPlantCode>
<pBlockCode>B</pBlockCode>
<pDateTimeFrom>2019-01-01T00:00:00.000+00:00</pDateTimeFrom>
<pDateTimeTo>2019-01-31T23:59:59.999+00:00</pDateTimeTo>
<pMaterial>Orange</pMaterial>
<pAmount>189567.055</pAmount>
<pAmountUnit>HW</pAmountUnit>
</row>
</ns0:MT_BD_QP_ECC>

Error Output

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_BD_QP_ECC xmlns:ns0="urn:BDG-is.com/xi/KWE/KIG/01_db">
<row>
<pSystemId>DUK</pSystemId>
<pRecordType>BD</pRecordType>
<pSourceSystem>SAPXI</pSourceSystem>
<pStatus>1</pStatus>
<pPlantCodeCHO</pPlantCode>
<pBlockCode>B</pBlockCode>
<pDateTimeFrom>2019-01-01T00:00:00.000+00:00</pDateTimeFrom>
<pDateTimeTo>2019-01-31T23:59:59.999+00:00</pDateTimeTo>
<pMaterial>Apple</pMaterial>
<pAmount>106789.055</pAmount>
<pAmountUnit>HW</pAmountUnit>
</row>
<row>
<pSystemId>DUK</pSystemId>
<pRecordType>BD</pRecordType>
<pSourceSystem>SAPXI</pSourceSystem>
<pStatus>1</pStatus>
<pPlantCode>CHO</pPlantCode>
<pBlockCode>B</pBlockCode>
<pDateTimeFrom>2019-01-01T00:00:00.000+00:00</pDateTimeFrom>
<pDateTimeTo>2019-01-31T23:59:59.999+00:00</pDateTimeTo>
<pMaterial>Orange</pMaterial>
<pAmount>189567.055</pAmount>
<pAmountUnit>HW</pAmountUnit>
</row>

In our mapping, we are using startElement / endElement (String uri, String localName, String qName) methods to Receive notification of the start and end of an element.

 public void endElement (String uri, String localName, String qName) throws SAXException
    {
		newContent = true;
    	
    	if(qName.equals("row"))
        {
            if(currentRecord.flag != null && 
               currentRecord.flag.equals("OK")) // Create result entry if flag OK set
            {
               if (targetsystem.equals("ECC")) // ECC Result
                {
                    // ECC is only interested in records having VTBT_DATUM >= 2010
                	if(Tools.DateHasValidYearECC(currentRecord.VTBT_DATUM, 2010))
                    {
                    	mapToTargetRecordsXem();
                    }
                }                
            }
        }
        else if(qName.equals("ES_MT_BD_QP_transit_ECC"))
        {  
            // end ECC result document
           result.append("</ns0:MT_BD_QP_ECC>");            
        }
    }
View Entire Topic
hasan_celebi
Participant
0 Likes

Hi Bhargava;

Xml document is not valid.


Regards
Hasan