# Convert XML String to CSV Flat file

**URL:** <https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761>\
**Category:** Forum\
**Tags:** EDI\
**Created:** [November 18, 2008, 9:17pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761 "2008-11-18T21:17:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mangatrai](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mangatrai](https://techcommunity.softwareag.com/u/mangatrai)\
**Post date:** [November 18, 2008, 9:17pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/1 "2008-11-18T21:17:53Z")

</div>

Hi,

I want to convert xml string to a csv flat file.

Is there any ready to use service available in webMethods API?

If not then can any one please help me out?

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![reamon](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@reamon](https://techcommunity.softwareag.com/u/reamon)\
**Post date:** [November 18, 2008, 9:42pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/2 "2008-11-18T21:42:25Z")

</div>

Your task will be little more involved than just calling a service. You’ll use several.

Read through the documentation about processing XML. And read the flat-file schema guide. The information there should be enough to get you started.

---

<div class="post-metadata">

**Author:** ![smile](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@smile](https://techcommunity.softwareag.com/u/smile)\
**Post date:** [December 18, 2008, 10:54pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/3 "2008-12-18T22:54:44Z")

</div>

Hi

Any one help me pls, this is urgent  
As per our requirement I am converting xml doc to csv file.If any tags missing in xml doc then csv file will missing the separator.

ex:  
xml file :

10 Luo 26 

CSV File:  
10,Luo,26

if xml missed one tag like

10 26 

Current CSV File: 10,26  
Excepted CSV File : 10,26

If you have any idea on this Pls share me ASAP

Cheers,  
Sashi.

---

<div class="post-metadata">

**Author:** ![mangatrai](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mangatrai](https://techcommunity.softwareag.com/u/mangatrai)\
**Post date:** [December 18, 2008, 11:57pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/4 "2008-12-18T23:57:32Z")

</div>

Use the field positioning when you are declaring fields in schema. you can find the option of fixed position in property window. I think this solution should work. If i find any other information i will keep you posted.

you can refer to schema documentation for more info.

Regards,  
Mangat Rai

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [December 19, 2008, 12:01am UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/5 "2008-12-19T00:01:20Z")

</div>

You should use the NthField (Index 1,2,3,4…) option in the FFSchema when you create FieldDefinitions for parsing/converting to CSV format…

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![mangatrai](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mangatrai](https://techcommunity.softwareag.com/u/mangatrai)\
**Post date:** [December 19, 2008, 1:53pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/6 "2008-12-19T13:53:06Z")

</div>

When you create flat file schema. In Flat file structure while declaring field definition, you need to provide set Extractor property. Use Nth field option Field = (0,1,2 etc…)  
this way if you get missing tag in XML, even then it will place a comma for that field place.

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [December 19, 2008, 7:52pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/7 "2008-12-19T19:52:38Z")

</div>

Mangatrai,

You are on the right track…we are trying to answer your original question and hope you got the solution now that you have requested for…

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:05pm UTC](https://techcommunity.softwareag.com/t/convert-xml-string-to-csv-flat-file/109761/8 "2021-04-02T15:05:51Z")

</div>


