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

Need to remove XML version header on XML Document

Former Member
0 Likes
1,816

Hello Everybody,

I am generating an XML file using an FTP adapter and in the generated XML we are having first line as

<XML vesrion ... >, is there any way to remove this line from XML document?

Please provide your inputs as soon as possible.

thanks,

Vijay Kumar T.

View Entire Topic
VijayKonam
Active Contributor
0 Likes

I do not know your requirement but, and XML file file without XML tag header is invalid as per w3c standards.

VJ

Former Member
0 Likes

Hi,

Yes, i know, but you can open XML file with out that header line and it is client requirement not to have that heade line for them to process on their side.

Thanks,

Vijay Kumar T.

Former Member
0 Likes

Hello Vijay,

It is possible using XSLT mapping. We had simliar requirement.I have done that.

1. Convert you input XML data in String. Below is the code to do that

<a:ReceiveXml>

<xml>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>

<xsl:copy-of select="VendorLink"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</xml>

</a:ReceiveXml>

2. Use Replace function of mapping to rempove XML declaration.

3. Convert String to XML data again usiong XSLT mapping.

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tns="your namespace">

<xsl:template match="/">

<xsl:for-each select="//tns:xml">

<xsl:value-of select="." disable-output-escaping="yes"/>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

You can find it on the SDN more about to convert XML to string and back to XML

Thanks

-Kulwant

Edited by: Kulwant Bhatia on Nov 12, 2008 4:06 PM

Former Member
0 Likes

Hi Kulwant,

thanks for your inputs,

i have used XSLT mapping to convert the XML file ( after graphical mapping ) to string, below is the code that i used

<?xml version='1.0' ?>

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

<xsl:template match="/">

<name>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>

<xsl:copy-of select="/"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</name>

</xsl:template>

</xsl:stylesheet>

with this above i am able to get entire xml document in one string but i am not able to see xml vesrion header line at all, it is having remaining data except first line.

Please suggest us.

Thanks,

Vijay Kumar T.