cancel
Showing results for 
Search instead for 
Did you mean: 

conversion of XML file in Noepad

Former Member
0 Kudos

Hi Folks,

i have a requiremnt like sending .TXT file and output is .XML.

when i open the file in internet explorer i Got right output. when open the same file in notepad the file is look like below

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

<EDS_PII_XML><Header><FILE_DATE></FILE_DATE></Header><Employee><EMPLID>010203</EMPLID><LAST_NAME>PUBLIC</LAST_NAME><FIRST_NAME>JOHN</FIRST_NAME><Deductions><DEDUCTION_CODE>HM</DEDUCTION_CODE><RECORD_TYPE>A</RECORD_TYPE><BEGIN_DT>2009-01-01</BEGIN_DT><END_DT></END_DT><PRE_TAX_COST>33.48</PRE_TAX_COST><AFTER_TAX_COST>0.00</AFTER_TAX_COST><OPTION>KAHI</OPTION><COVERAGE_LEVEL>EF</COVERAGE_LEVEL><IMPUTED_INCOME>0.00

but i need the file like below:

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

<EDS_PII_XML>

<Header>

<FILE_DATE></FILE_DATE>

</Header>

<Employee>

<EMPLID>010203</EMPLID>

<LAST_NAME>PUBLIC</LAST_NAME>

<FIRST_NAME>JOHN</FIRST_NAME>

<Deductions>

<DEDUCTION_CODE>HM</DEDUCTION_CODE>

<RECORD_TYPE>A</RECORD_TYPE>

<BEGIN_DT>2009-01-01</BEGIN_DT>

<END_DT/>

<PRE_TAX_COST>33.48</PRE_TAX_COST>

<AFTER_TAX_COST>0.00</AFTER_TAX_COST>

<OPTION>KAHI</OPTION>

<COVERAGE_LEVEL>EF</COVERAGE_LEVEL>

<IMPUTED_INCOME>0.00</IMPUTED_INCOME>

<GOAL_AMOUNT>0.00</GOAL_AMOUNT>

</Deductions>

<Deductions>

<DEDUCTION_CODE>HS</DEDUCTION_CODE>

<RECORD_TYPE>A</RECORD_TYPE>

<BEGIN_DT>2009-01-01</BEGIN_DT>

<END_DT/>

<PRE_TAX_COST>15.25</PRE_TAX_COST>

<AFTER_TAX_COST>0.00</AFTER_TAX_COST>

<OPTION>01</OPTION>

<COVERAGE_LEVEL>EF</COVERAGE_LEVEL>

<IMPUTED_INCOME>0.00</IMPUTED_INCOME>

<GOAL_AMOUNT>150.00</GOAL_AMOUNT>

Any conversion is there in XI?

please let me know ASAP.

points also rewarded.

Thanks

Anil M

Accepted Solutions (0)

Answers (6)

Answers (6)

jan_krohn
Active Participant
0 Kudos

Hi Anil,

You can do the conversion with XSLT. Here's the code:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output encoding="utf-8" indent="yes" method="xml" version="1.0"/>

<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">

<xsl:copy>

<xsl:apply-templates select="@*|node()"/>

</xsl:copy>

</xsl:template>

</xsl:transform>

(This copies the complete XML, and created a formatted output - indent="yes". All other content remains untouched.)

How to integrate in SAP, read here: http://www.heidoc.net/joomla/en/technology-science/sap-and-xslt/5-tutorial-data-exchange-between-aba...

Best wishes,

Jan

Edited by: Jan Krohn on Jul 15, 2011 10:57 AM

aashish_sinha
Active Contributor
0 Kudos

Hi ,

As discussed and suggested by Aamir and Stefan, you have to use a newline charcter after each end tag.

For this purpose you need to write an UDF.

You can refer this link for this UDF.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/howtoappendCarriageReturnintheendofeachtagofxml+file.

Regards

Aashish Sinha

Former Member
0 Kudos

Hi Sinha,

Thanks for your help.

Still i am in confusion.how and where we need to provide this UDF. I mean on sender side or reciver side?

Thanks

Anil M

stefan_grube
Active Contributor
0 Kudos

There is no standard for so-called whitespaces in XML, therefore PI does not provide any function to insert them automatically.

If you need line-feeds or tabs, then you have to provide them by a self-written Java mapping or XSLT mapping.

Regards

Stefan

Former Member
0 Kudos

Anil

Wrong Direction file ?

Provide more info on what exactly you are looking for with the output. So that we can try to solve.

Thanks

Gaurav

Former Member
0 Kudos

Notepad is not a XML editor,it does not recognise the XML tags,

Open the XML file in MS word and will look exactly like it does in IE

Thanx

Aamir

Former Member
0 Kudos

Hi,

IE can distingush XML with another files...that is the reason it showed you correctly, but Note pad don't have that feature... if there is a space between each tag than by using wrod wrap it can show you as IE,but in your file there will be no space after each tag.

Former Member
0 Kudos

Hi,

There is no space between tags. Even though i am getting wrong direction file

Former Member
0 Kudos

hey Anil,

Notepad can't open an XML in XML format as IE. so tell us exactly your requirement, we can try other options....

Former Member
0 Kudos

Anil

You want to send text file or XML content in .txt file?

For converting XML into Txt you can use File Content Conversion in your Receiver Channel Configuration for File Adapter.

Thanks

Gaurav