# Issue with Xml Reader

**URL:** <https://forum.cloverdx.com/t/issue-with-xml-reader/1749>\
**Category:** CloverDX Platform\
**Created:** [May 4, 2016, 12:00am UTC](https://forum.cloverdx.com/t/issue-with-xml-reader/1749 "2016-05-04T00:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madan\_clover3](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@madan\_clover3](https://forum.cloverdx.com/u/madan_clover3)\
**Post date:** [May 4, 2016, 12:00am UTC](https://forum.cloverdx.com/t/issue-with-xml-reader/1749/1 "2016-05-04T00:00:00Z")

</div>

Hi,

Trying to read xml data with XmlReader. Below are data and mapping files,

Mapping file 2 and 3 working fine. Mapping file 1 is giving exception (added below). Please clarify me is it expected behavior or issue with component.

Data File :  
  
  
**field21value**  
**field22value**  
  
  
**field22value**  
**field23value**  
  
  
**field212value**

Mapping File 1 :  
**// DOES NOT WORK**  
**\<?xml version="1.0" encoding="UTF-8"?\>**

**ERROR MESSAGE :**  
**Exception occured while transforming data.Component [XML\_Reader] finished with status ERROR. (Out0: 1 recs, Out1: 0 recs)**  
**XPath ‘Entity2’ contains two or more values!**

Mapping File 2 :  
// WORKS FINE

\<?xml version="1.0" encoding="UTF-8"?\> 

Mapping File 3 :  
// WORKS FINE

\<?xml version="1.0" encoding="UTF-8"?\> 

Thank you,  
Madan

---

<div class="post-metadata">

**Author:** ![PedroVazquezRosario](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PedroVazquezRosario](https://forum.cloverdx.com/u/PedroVazquezRosario)\
**Post date:** [May 5, 2016, 3:25pm UTC](https://forum.cloverdx.com/t/issue-with-xml-reader/1749/2 "2016-05-05T15:25:25Z")

</div>

Hi,

That is the expected behavior for the XMLReader the reason being is since Entity2 is ambiguous CloverETL can’t determine which element to choose from. When you define a Context tag the element shouldn’t be ambiguous, you should specify to the exact element you want to read from. In this case the second mapping approach is the best option, but I would recommend that you use a single xpath expression:

```auto
xpath=”/Dataset/Entity2/Entity21”

```

I would also recommend that you use the XMLExtract component, the reason being it’s easier to use and safer in terms of out of memory issues.

---

<div class="post-metadata">

**Author:** ![madan\_clover3](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@madan\_clover3](https://forum.cloverdx.com/u/madan_clover3)\
**Post date:** [May 10, 2016, 8:16am UTC](https://forum.cloverdx.com/t/issue-with-xml-reader/1749/3 "2016-05-10T08:16:24Z")

</div>

Thanks for explanation. I have tried Xml Extract as well. Problem with Xml Extract(SAX way) is we cannot map one source element to multiple target elements. In such case only last mapped element is getting data. (only fld3, fld4 is getting data in below case)

Any better approach with above case, suggestions please.

Thank you.

---

<div class="post-metadata">

**Author:** ![PedroVazquezRosario](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PedroVazquezRosario](https://forum.cloverdx.com/u/PedroVazquezRosario)\
**Post date:** [May 13, 2016, 3:37pm UTC](https://forum.cloverdx.com/t/issue-with-xml-reader/1749/4 "2016-05-13T15:37:50Z")

</div>

Hi,

Unfortunately, you can’t map the same element to two different output ports. I would recommend that you extract the field first and then use SimpleCopy or Reformat to map the source elements to multiple target elements.

Best Regards,
