LOCAL [TryFunction] RemoveNameSpace(XMLSourceStream : InStream;VAR XMLDestinationStream : InStream) XSLTString := '<?xml version="1.0" encoding="UTF-8"?>'; XSLTString := XSLTString + '<xsl:stylesheet version="1.0" ' + 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >'; XSLTString := XSLTString + '<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>'; XSLTString := XSLTString + '<xsl:template match="/">'; XSLTString := XSLTString + '<xsl:copy>'; XSLTString := XSLTString + '<xsl:apply-templates />'; XSLTString := XSLTString + '</xsl:copy>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="soap:Header">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="*">'; XSLTString := XSLTString + '<xsl:element name="{local-name()}">'; XSLTString := XSLTString + '<xsl:apply-templates select="@* | node()" />'; XSLTString := XSLTString + '</xsl:element>'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="@*">'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '<xsl:template match="text() | processing-instruction() | comment()">'; XSLTString := XSLTString + '<xsl:copy />'; XSLTString := XSLTString + '</xsl:template>'; XSLTString := XSLTString + '</xsl:stylesheet>'; StringReader := StringReader.StringReader(XSLTString); XsltXMLReader := XsltXMLReader.Create(StringReader); XslCompiledTransform := XslCompiledTransform.XslCompiledTransform; XslCompiledTransform.Load(XsltXMLReader); XmlReaderSettings := XmlReaderSettings.XmlReaderSettings; SourceXMLReader := SourceXMLReader.Create(XMLSourceStream,XmlReaderSettings); DestinationXMLWriter := DestinationXMLWriter.Create(XMLDestinationStream); XslCompiledTransform.Transform(SourceXMLReader,DestinationXMLWriter);
Answers
//DELETE ROOT NODE
RootNode := '<?xml version="1.0" encoding="utf-8" standalone="no"?>';
xml := DELSTR(xml,1, STRLEN(RootNode));
I tried but didnt work. Applied followink links.
Link : https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/
I get this error;
Cannot serialize an instance of the following .NET Framework object: assembly Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, type MSXML.DOMDocumentClass.
XslCompiledTransform DotNet System.Xml.Xsl.XslCompiledTransform.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XsltXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XSLTString Text
SourceXMLReader DotNet System.Xml.XmlReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
DestinationXMLWriter DotNet System.Xml.XmlWriter.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
StringReader DotNet System.IO.StringReader.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlReaderSettings DotNet System.Xml.XmlReaderSettings.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Thanks for your help.
I just want to remind that were 2 minor problems.
First I had to remove semicolons
second I added following line in order to preserve attributes
XSLTString := XSLTString + '<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>';
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-automation-variable/
https://rockwithnav.wordpress.com/2016/03/29/remove-namespace-web-service-response-dotnet-variable/
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/